FUNCTION hsi_pmtras_dbase_expand, datin ; ; Returns structure containing roll solution in format suitable for imaging software. ; Input is structure containing condensed-format structure from either _ssw or _master roll database. ; ; Output is the corresponding roll solution structure with monatonically increasing position angles (radians) ; ; 16-Aug-03 gh Initial version (adapted from hsi_pmtras_lookup code) ; 18-Aug-03 gh Simplified input arguments. ; 16-Mar-04 gh Add provision to use accurate, previous spin period if gap is > ~5 minutes. ; twopi = 2. * !DPI two56pi = 256. * !DPI nok = N_ELEMENTS(datin) sctime0 = {seconds: 0L, $ bmicro: 0L} ; Define a proper s/c time structure sctime0.seconds = datin[0].sctime ; sctime0.bmicro == 0 pmtras_solution = {t0_ref: sctime0, $ ; t0_ref = time of 1st output datum reltime: DBLARR(nok), $ ; DBL seconds relative to t0_ref posn_angle: DBLARR(nok) } ; monatonically increasing radians. t0 = sctime0.seconds ; t0 in seconds (LONG) (will be integral of 64 s) pmtras_solution.reltime = datin.sctime - t0 ; offset in DBL seconds (will be integral of 64 s) rotation_angle = datin.roll_phase*1.E-6/(twopi) ; convert phase to FP rotations rotations_per_second = datin.approx_angvel / two56pi ; convert to rotations/s FOR n=1,nok-1 DO BEGIN avg_rps = (rotations_per_second[n] + rotations_per_second[n-1])/2 dt = pmtras_solution.reltime[n] - pmtras_solution.reltime[n-1] IF n GE 2 AND dt GT 256 THEN $ ; Use accurate previous value of avg_rps if gap is longer than ~5 minutes. avg_rps = (rotation_angle[n-1]-rotation_angle[n-2]) / (pmtras_solution.reltime[n-1]-pmtras_solution.reltime[n-2]) rotation_angle[n] = rotation_angle[n] + FIX(rotation_angle[n-1]) rotation_angle[n] = rotation_angle[n] + ROUND((pmtras_solution.reltime[n] - pmtras_solution.reltime[n-1]) * avg_rps $ - (rotation_angle[n] - rotation_angle[n-1])) ENDFOR pmtras_solution.posn_angle = rotation_angle * twopi ; final result is in monatonically increasing radians RETURN, pmtras_solution END