pro makecaltfiles ; Paul Withers, 2008.09.10 ; Center for Space Physics, Boston University ; Make PDS label files for calt files common bigpdsblock ;caltdir = '../pdsproc02/pdscalt/' caltdir = 'toplevelpdsdir/DATA/CALT/' spawn, 'ls -1 ' + caltdir + '*TAB', caltarr junk = caltarr caltarr(0:n_elements(caltarr)/2 - 1) = junk(n_elements(caltarr)/2:*) caltarr(n_elements(caltarr)/2:*) = junk(0:n_elements(caltarr)/2 - 1) ; Have to reverse order from in then out to out then in ; Sequence in the scet files is out, then in. i=0 while i lt n_elements(caltarr) do begin junk = str_sep(caltarr(i), '/') caltarr(i) = junk(n_elements(junk)-1) i=i+1 endwhile caltprefix = caltarr nz = n_elements(caltarr) j=0 while j lt nz do begin junk = str_sep(caltarr(j), '.') xxx = str_sep(junk(0), '/') caltprefix(j) = xxx(n_elements(xxx)-1) ; junk(0) ; unnecessarily complicated now I've ditched the leading ; directory names, but it still works j=j+1 endwhile firstgoodscet = strarr(nz) lastgoodscet = strarr(nz) norbs = 0L openr, lun1, 'firstgoodscet.txt', /get_lun readf, lun1, firstgoodscet free_lun, lun1 openr, lun1, 'lastgoodscet.txt', /get_lun readf, lun1, lastgoodscet free_lun, lun1 openr, lun1, 'norbsforcalt.txt', /get_lun readf, lun1, norbs free_lun, lun1 norbsstr = strcompress(string(fix(norbs)), /remove_all) j=0 while j lt nz do begin preamble = strarr(23) i=0 preamble(i) = bigpdsstruct.pdsversionid & i=i+1 preamble(i) = bigpdsstruct.blankstr & i=i+1 preamble(i) = bigpdsstruct.fixedlength & i=i+1 preamble(i) = bigpdsstruct.recbytes + '213' & i=i+1 preamble(i) = bigpdsstruct.filerecords + norbsstr & i=i+1 preamble(i) = bigpdsstruct.carettable + caltarr(j) + '"' & i=i+1 preamble(i) = bigpdsstruct.blankstr & i=i+1 preamble(i) = bigpdsstruct.datasetid & i=i+1 preamble(i) = bigpdsstruct.missionname & i=i+1 preamble(i) = bigpdsstruct.instrumenthostname & i=i+1 preamble(i) = bigpdsstruct.instrumentname & i=i+1 preamble(i) = bigpdsstruct.productid + caltarr(j) + '"' & i=i+1 preamble(i) = bigpdsstruct.targetname & i=i+1 ;preamble(i) = bigpdsstruct.sclkstart & i=i+1 ;preamble(i) = bigpdsstruct.sclkstop & i=i+1 preamble(i) = bigpdsstruct.timestart + firstgoodscet(j) & i=i+1 preamble(i) = bigpdsstruct.timestop + lastgoodscet(j) & i=i+1 preamble(i) = bigpdsstruct.prodcreationtime + $ bigpdsstruct.productcreationdateyyyymmdd & i=i+1 preamble(i) = bigpdsstruct.blankstr & i=i+1 preamble(i) = bigpdsstruct.objecttable & i=i+1 preamble(i) = bigpdsstruct.ifascii & i=i+1 preamble(i) = bigpdsstruct.rowbytes + '213' & i=i+1 preamble(i) = bigpdsstruct.rows + norbsstr & i=i+1 preamble(i) = bigpdsstruct.cols + '15' & i=i+1 preamble(i) = bigpdsstruct.blankstr & i=i+1 ;help, i eq3 = '= 3' eqa3 = '= "A3"' eq25 = '= 25' eqa25 = '= "A25"' eq14 = '= 14' eqe14p5 = '= "E14.5"' eqf14p5 = '= "F14.5"' headertable = strarr(174) ; update length as needed i=0 ;headertable(i) = 'OBJECT = ACC_CALT_TABLE' & i=i+1 ;headertable(i) = ' INTERCHANGE_FORMAT = ASCII' & i=i+1 ;headertable(i) = ' ROW_BYTES = 213' & i=i+1 ;headertable(i) = ' ROWS = 1' & i=i+1 ;headertable(i) = ' COLUMNS = 15' & i=i+1 ;headertable(i) = '' & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "ORBIT_NUMBER_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '1' & i=i+1 headertable(i) = bigpdsstruct.colreptypeint & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 1' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq3 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqa3 & i=i+1 headertable(i) = bigpdsstruct.colunitdimless & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Orbit number."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "TIME_UTC_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '2' & i=i+1 headertable(i) = bigpdsstruct.colreptypechar & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 4' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq25 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqa25 & i=i+1 headertable(i) = bigpdsstruct.colunitdimless & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Time (UTC) when spacecraft is' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "LATITUDE_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '3' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 29' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqf14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdegn & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Areocentric latitude, degrees north, of' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' spacecraft at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "LONGITUDE_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '4' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 43' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqf14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdege & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Areocentric longitude, degrees east, of' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' spacecraft at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "LST_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '5' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 57' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqf14p5 & i=i+1 headertable(i) = bigpdsstruct.colunithour & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Local true solar time at spacecraft' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "SZA_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '6' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 71' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqf14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdeg & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Solar zenith angle at spacecraft' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "LS_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '7' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 85' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqf14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdeg & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Ls of Mars when spacecraft is' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "RHO_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '8' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 99' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkgperm3 & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Fitted atmospheric density' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "SRHO_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '9' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 113' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkgperm3 & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "One sigma uncertainty in RHO_CALT."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "DSH_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '10' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 127' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkm & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Fitted density scale height' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "SDSH_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '11' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 141' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkm & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "One sigma uncertainty in DSH_CALT."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "TEMP_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '12' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 155' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkelvin & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Fitted temperature' & i=i+1 headertable(i) = bigpdsstruct.colpartblank + ' at reference altitude."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "STEMP_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '13' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 169' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitkelvin & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "One sigma uncertainty in TEMP_CALT."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "REDCHISQD_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '14' & i=i+1 headertable(i) = bigpdsstruct.colreptype & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 183' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdimless & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Reduced chi-squared for fit."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 headertable(i) = bigpdsstruct.colrepstart & i=i+1 headertable(i) = bigpdsstruct.colpartname + '= "NPTS_CALT"' & i=i+1 headertable(i) = bigpdsstruct.colnumber + '15' & i=i+1 headertable(i) = bigpdsstruct.colreptypeint & i=i+1 headertable(i) = bigpdsstruct.colpartsbyte + '= 197' & i=i+1 headertable(i) = bigpdsstruct.colpartbytes + eq14 & i=i+1 headertable(i) = bigpdsstruct.colpartformat + eqe14p5 & i=i+1 headertable(i) = bigpdsstruct.colunitdimless & i=i+1 headertable(i) = bigpdsstruct.colpartdesc + '= "Number of data points used for fit."' & i=i+1 headertable(i) = bigpdsstruct.colrepend & i=i+1 headertable(i) = bigpdsstruct.blankstr & i=i+1 ending = strarr(3) ending(0) = bigpdsstruct.tablerepend & i=i+1 ending(1) = bigpdsstruct.blankstr & i=i+1 ending(2) = bigpdsstruct.fileend & i=i+1 i=0 while i lt n_elements(preamble) do begin if strlen(preamble(i)) ge bigpdsstruct.maxstrlen then stop preamble(i) = preamble(i) + bigpdsstruct.blankline junk = strmid(preamble(i),0,bigpdsstruct.maxstrlen) preamble(i) = junk i=i+1 endwhile i=0 while i lt n_elements(headertable) do begin if strlen(headertable(i)) ge bigpdsstruct.maxstrlen then stop headertable(i) = headertable(i) + bigpdsstruct.blankline junk = strmid(headertable(i),0,bigpdsstruct.maxstrlen) headertable(i) = junk i=i+1 endwhile i=0 while i lt n_elements(ending) do begin if strlen(ending(i)) ge bigpdsstruct.maxstrlen then stop ending(i) = ending(i) + bigpdsstruct.blankline junk = strmid(ending(i),0,bigpdsstruct.maxstrlen) ending(i) = junk i=i+1 endwhile ;print, transpose(preamble) ;print, transpose(headertable) ;print, transpose(ending) openw, lun1, caltdir + caltprefix(j) + '.LBL', /get_lun printf, lun1, transpose(preamble) printf, lun1, transpose(headertable) printf, lun1, transpose(ending) free_lun, lun1 j=j+1 endwhile end