; ; BITVCONV ; ; Accepts a set of ATDF records and derives more useful quantities, ; which can be printed out to an output file. ; ; RECS - array of IDL structures containing ATDF records, as ; produced by BITVREAD ; ; CONV - converted records. Derived quantities are more useful ; ; OUTUNIT - optional out put file unit where ASCII representation of ; derived records are written. ; ; KEYWORD TAI - if set, then compute TAI instead of UTC (requires ; TAI_UTC). ; ; NOTE: This routine uses TAI_UTC from the Markwardt web page at ; http://cow.physics.wisc.edu/idl/ If you aren't concerned about ; leap seconds (i.e., the difference between TAI and UTC), then ; do not pass the TAI keyword. ; ; $Id: bitvconv.pro,v 1.5 2002/07/04 14:39:34 craigm Exp $ ; ; C. Markwardt 03 Feb 2002 ; pro bitvconv, recs, conv, outunit, first=first, tai=tai, $ rampconv=rampconv, rampunit=rampunit, $ data_types=dtypes, ground_modes=gmodes, $ ngood=nrec convtemp = {record_type: 0L, date: intarr(5), spacecraft: 0b, $ julian_date: 0d, tai: 0d, doppler_cnt: 0d, fsky: 0d, $ net_id: 0b, station: 0b, uplink_band: 0b, downlink_band: 0b, $ data_type: 0b, ground_mode: 0b, range_type: 0b, $ angle_type: 0b, drvid_type: 0b, doppler_good0: 0b, $ doppler_tol0: 0b, doppler_bias: 0, angle_good0: 0b, $ rcvr_lock0: 0b, xmtr_on0: 0b, source_desig: 0b, $ sampler_time: 0., range_data: 0d, $ doppler_ref: 0d, rtlight: 0l, doppler_resid: 0d, $ range_resid: 0l, conscan_mode: 0b, doppler_channel: 0b, $ slipped_cycle: 0L, doppler_noise: 0d, signal_strength: 0d, $ diff_doppler_phase: 0d, range_valid0: 0b, rcvr_number: 0b, $ avg_doppler_resid: 0d, ramp_ctrl: 0b, ramp_rate: 0d, $ ramp_delay: 0d, ramp_start: 0d, xmtr_freq: 0d} nrec = n_elements(recs) conv = replicate(convtemp, nrec) conv.record_type = recs.record_type conv.date(0) = recs.year_tag + 1900 conv.date(1) = recs.day_tag conv.date(2) = recs.hour_tag conv.date(3) = recs.minute_tag conv.date(4) = recs.second_tag jdutc = jday(conv.date(0),1d,1d) + conv.date(1)-1 jdutc = jdutc + (recs.hour_tag + (recs.minute_tag + $ recs.second_tag/60d)/60d)/24d conv.julian_date = jdutc forward_function tai_utc if keyword_set(tai) then ttai = tai_utc(jdutc)/86400d else ttai = 0 jdtai = jdutc + ttai conv.tai = (jdtai - jday(2000,1,1.5))*86400d conv.net_id = recs.net_id conv.station = recs.station conv.spacecraft = recs.spacecraft conv.downlink_band = recs.downlink_band conv.data_type = recs.data_type conv.ground_mode = recs.ground_mode conv.range_type = recs.range_type conv.angle_type = recs.angle_type conv.drvid_type = recs.drvid_type conv.doppler_good0 = recs.doppler_good0 conv.doppler_tol0 = recs.doppler_tol0 conv.doppler_bias = recs.doppler_bias conv.angle_good0 = recs.angle_good0 conv.rcvr_lock0 = recs.rcvr_lock0 conv.xmtr_on0 = recs.xmtr_on0 conv.source_desig = recs.source_desig conv.sampler_time = recs.sampler_time / 100 conv.doppler_ref = recs.doppler_ref / 10d conv.doppler_resid = recs.doppler_resid / 1000d conv.range_resid = recs.range_resid conv.uplink_band = recs.uplink_band conv.conscan_mode = recs.conscan_mode conv.doppler_channel = recs.doppler_channel conv.slipped_cycle = recs.slipped_cycle conv.doppler_noise = recs.doppler_noise / 1000d conv.signal_strength = recs.signal_strength / 10d conv.diff_doppler_phase= recs.diff_doppler_phase / 1000d conv.range_valid0 = recs.range_valid0 conv.rcvr_number = recs.rcvr_number conv.avg_doppler_resid = recs.avg_doppler_resid / 1000d conv.ramp_ctrl = recs.ramp_ctrl conv.ramp_rate = recs.ramp_rate / 1d6 conv.xmtr_freq = recs.xmtr_freq / 10d conv.rtlight = recs.doppler_cnt2_lp conv.range_data = recs.range_data1*10000d + recs.range_data2/1000d conv.doppler_cnt = recs.doppler_cnt_hp*10000d + $ recs.doppler_cnt_lp/1000d conv.ramp_start = recs.ramp_start1*10d + recs.ramp_start2/1d6 conv.ramp_delay = recs.diff_s_x_range*1d-9 dtype = conv.data_type wh = where(dtype EQ 6, ct) if ct GT 0 then begin rampconv = conv(wh) endif else begin rampconv = 0 & dummy = temporary(rampconv) endelse mask1 = dtype NE dtype ;; Array of zeroes if n_elements(dtypes) EQ 0 then begin mask1 = dtype NE 6 endif else begin for i = 0, n_elements(dtypes)-1 do begin if dtypes(i) LT 0 then $ mask1 = mask1 AND (dtype NE dtypes(i)) $ else $ mask1 = mask1 OR (dtype EQ dtypes(i)) endfor endelse gmode = conv.ground_mode mask2 = gmode NE gmode ;; Array of zeroes for i = 0, n_elements(gmodes)-1 do begin if gmodes(i) LT 0 then $ mask2 = mask2 AND (gmode NE gmodes(i)) $ else $ mask2 = mask2 OR (gmode EQ gmodes(i)) endfor if n_elements(gmode) EQ 0 then $ mask2(*) = 1 wh = where(mask1 AND mask2, nrec) if nrec EQ 0 then return conv = conv(wh) sdoppler = (conv.doppler_bias GE 0)*2L - 1 dcnt = conv.doppler_cnt doff = (dcnt(1:*) LT dcnt)*(2d^32) drate = (dcnt(1:*)+doff-dcnt)/conv.sampler_time conv(0:nrec-2).fsky = (96d*240d/221d*conv.doppler_ref - 2292d6) $ - sdoppler*(drate - 1d6) for i = 0, 1 do begin if i EQ 0 then begin if n_elements(outunit) GE 0 then unit = outunit(0) $ else goto, NEXT_UNIT endif else begin if n_elements(rampunit) GE 0 then unit = rampunit(0) $ else goto, NEXT_UNIT endelse if keyword_set(first) then begin printf, unit, '; 1 - RECORD TYPE' printf, unit, '; 2 - YEAR' printf, unit, '; 3 - DAY' printf, unit, '; 4 - HOUR' printf, unit, '; 5 - MINUTE' printf, unit, '; 6 - SECOND' printf, unit, '; 7 - SPACECRAFT ID' printf, unit, '; 8 - JULIAN DATE (UTC)' printf, unit, '; 9 - TAI (CLOCK SECONDS SINCE 1.5 JAN 2000)' printf, unit, '; 10 - DOPPLER COUNT (CYCLES)' printf, unit, '; 11 - FSKY (FSKY MINUS 2292000000 Hz)' printf, unit, '; 12 - NET_ID' printf, unit, '; 13 - STATION' printf, unit, '; 14 - UPLINK_BAND' printf, unit, '; 15 - DOWNLINK_BAND' printf, unit, '; 16 - DATA_TYPE' printf, unit, '; 17 - GROUND_MODE' printf, unit, '; 18 - RANGE_TYPE' printf, unit, '; 19 - ANGLE_TYPE' printf, unit, '; 20 - DRVID_TYPE' printf, unit, '; 21 - DOPPLER_GOOD0' printf, unit, '; 22 - DOPPLER_TOL0' printf, unit, '; 23 - DOPPLER_BIAS' printf, unit, '; 24 - ANGLE_GOOD0' printf, unit, '; 25 - RCVR_LOCK0' printf, unit, '; 26 - XMTR_ON0' printf, unit, '; 27 - SOURCE_DESIG' printf, unit, '; 28 - SAMPLER_TIME (SECONDS)' printf, unit, '; 29 - RANGE_DATA (RANGE UNITS)' printf, unit, '; 30 - DOPPLER REFERENCE (Hz)' printf, unit, '; 31 - RTLIGHT - ROUND TRIP LIGHT TIME (SECONDS)' printf, unit, '; 32 - DOPPLER_RESID (Hz)' printf, unit, '; 33 - RANGE_RESID (RANGE UNITS)' printf, unit, '; 34 - CONSCAN MODE' printf, unit, '; 35 - DOPPLER_CHAN' printf, unit, '; 36 - SLIPPED_CYCLE (CYCLES)' printf, unit, '; 37 - DOPPLER_NOISE (Hz)' printf, unit, '; 38 - SIGNAL_STRENGTH (VOLT)' printf, unit, '; 39 - DIFF_DOPPLER_PHASE (CYCLES)' printf, unit, '; 40 - RANGE_VALID0' printf, unit, '; 41 - RCVR_NUMBER' printf, unit, '; 42 - AVG_DOPPLER_RESID (Hz)' printf, unit, '; 43 - RAMP_CTRL' printf, unit, '; 44 - RAMP_RATE (Hz)' printf, unit, '; 45 - RAMP_DELAY (SECONDS)' printf, unit, '; 46 - RAMP_START (Hz)' printf, unit, '; 47 - XMTR_FREQ (Hz)' printf, unit, $ '; ----------------------------------------------------- ' endif ; type YYYYDDD hh mm ss SC JD TAI cnt fsky fmt= ('(I4,I5,I4.3,I3.2,I3.2,I3.2,I4,D15.5,I12,D15.3,G15.10,' +$ 'I3,I4,I2,I2, I2,I2,I2, I2,I2,I2, I2,I4,I2, I2,I2,I2,' +$ 'D9.2,D20.6, G14.9,I11,G16.9, I11,I2,I2, I5,D10.3,G10.7,' +$ 'G10.7,I2,I2, G12.8,I2,D10.6, E15.8,D20.8,D13.2)') if i EQ 0 then begin printf, unit, conv, format=fmt print, 'Printed ', n_elements(conv), ' doppler records' endif else begin if n_elements(rampconv) GT 0 then $ printf, unit, rampconv, format=fmt endelse NEXT_UNIT: endfor return end