
function get_mpo, t0, t1, ds=ds, threeh=threeh, weekly=weekly

;+
;   Name: ssw_sdo_master_pointing
;
;   Purpose: Get SDO master pointing records between t0 and t1
;
;   Keyword Parameters:
;      ds - data series to use - default is three hour cadence series
;
;   Method:
;      Use ssw_jsoc_time2data
;
;   History:
;      2017-06-17 - GLS
;      2018-02-11 - Ryan Timmons, changing 3h seris to
;                   aia.master_pointing3h based on JPS advice
;      Tue Dec 10 13:29:51 2024, Randolf Klein <rklein@.lmsal.com>
;      Added workaround for failing JSCO querry while the SDO data flow is down
;      Calls read_full_mpo_20241122
;-

if not exist(t0) then return, -1
if not exist(t1) then return, -1

if not exist(ds) then ds = 'aia.master_pointing3h'
if keyword_set(threeh) then ds = 'aia.master_pointing3h'
if keyword_set(weekly) then ds = 'aia.master_pointing'

ssw_jsoc_time2data, t0, t1, mpo_str, ds=ds
if n_elements(mpo_str) ne 0 then begin
   return, mpo_str
endif else begin
   if keyword_set(weekly) then message,'Keyword "weekly" is not implemented in the workaround while JSOC is down'
   mpo = read_full_mpo_20241122()

   t0_s = anytim(t0)
   t1_s = anytim(t1)
   
   if t1_s lt t0_s then begin
      tt=t1_s & t1_s=t0_s & t0_s = tt
   endif

   t_start = anytim(mpo.t_start)
   t_stop = anytim(mpo.t_stop)
   
   idx = where(t0_s lt t_start and t_stop lt t1_s,cnt)
   if cnt eq 0 then return,-1 else return, mpo[idx]
endelse
end
