;+ ; NAME: ; oc_write_lc_fgnom ; PURPOSE: (one line) ; Write a lightcurve fits table ; CATEGORY: ; Occultation ; CALLING SEQUENCE: ; oclc_write_fgnom, target, date_obs, sec_mid, lc, rastr, decstr, latstr, lonstr, site_name ; INPUTS: ; target - string, used to look up NAIF id ; date_obs - string in FITS header format, YYYY-MM-DD ; sec_mid - seconds since 00:00 UTC on data_obs, of the midtime of the bin ; lc - lightcurve, normalized 0 for no star to 1 for complete star ; lc and sec_mid are both N elements long ; rastr = RA string, 'hh:mm:ss.ss' ; decstr = Declination string, 'dd:mm:ss.sss' ; latstr - Latitude string, referenced to WGS-84 ; lonstr - Longitude string, referenced to WGS-84 ; site_name - string. Also used for file name ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; kernel - string. Name of kernel to load. ; lc_err - error in lc (N elements) ; lc_ref - string. reference for the lightcurve ; flux - original flux, Pluto + star, in DN or other "natural" ; units. N elements long ; flux_err - error in the lightcurvce ; flux_ref - reference for the flux ; qualflag - quality flag. N elements long. 0 = good. Any other = bad ; qualhist - Array of strings. HISTORY comments explaining qual ; itime - integration time of each bin, sec. N elements long ; time_ref - reference for the time of each bin ; alt - altitude (km) ; site_ref - string. reference for lat, lon, alt ; site_label - string. Label in plots, etc. ; observer - observers (string) ; instrument - instruemtn (string) ; wavelen - wavelength (micron) ; outdir - string, ending '/'. directory for output (default = ''). ; version - file version number ; SIDE EFFECTS: ; writes ; RESTRICTIONS: ; None ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2000 October, by Leslie Young, SwRI ; Nov 2000. Allow non-scalar argument, LAY ;- pro oc_write_lc_fgnom, target, date_obs, sec_mid, lc, rastr, decstr, latstr, lonstr, site_name, $ kernel = kernel, $ lc_err=lc_err, lc_ref=lc_ref, flux=flux, flux_err=flux_err, flux_ref=flux_ref, qualflag=qualflag, qualhist=qualhist, $ itime = itime, time_ref=time_ref, $ radec_star_ref=radec_star_ref, $ alt=alt, site_ref=site_ref, site_label=site_label, $ observer=observer, telescope=telescope, instrument=instrument, $ wavelen=wavelen, $ outdir = outdir, version=version naifreinit, kernel = kernel n = n_elements(sec_mid) ;*********************** ; Get the lc, lc_err, lc_ref, flux, flux_err, flux_ref ;*********************** if not keyword_set(lc_err) then lc_err = replicate(-999., n) if not keyword_set(lc_ref) then lc_ref='Unknown' if not keyword_set(flux) then flux = replicate(-999., n) if not keyword_set(flux_err) then flux_err = replicate(-999., n) if not keyword_set(flux_ref) then flux_ref='Unknown' if not keyword_set(qualflag) then qualflag = replicate(0,n) if not keyword_set(qualhist) then qualhist = '' if not keyword_set(outdir) then outdir = '' targetcode = naif_id(target, targetfound) if targetfound ne 1 then begin print, 'Target not understood by CSPICE_BOD2N or wrong data type' stop endif ;*********************** ; Get the times ;*********************** et_date = utc2et(date_obs) et_mid = et_date + double(sec_mid) utc_mid = et2utc(et_mid) if not keyword_set(itime) then begin sec_end = dblarr(n) sec_start = dblarr(n) sec_end[0:n-2] = sec_mid[1:n-1] + sec_mid[0:n-2] sec_start[1:n-1] = sec_end[0:n-2] sec_start[0] = sec_mid[0] - (sec_end[0] - sec_mid[0]) sec_end[n-1] = sec_mid[n-1] + (sec_mid[n-1] - sec_start[n-1]) itime = sec_end - sec_start itime[0] = itime[1] itime[n-1] = itime[n-2] endif if not keyword_set(time_ref) then flux_ref='Unknown' ;*********************** ; Get the star ;*********************** ra = raparse(rastr) dec = decparse(decstr) radec_star = [ra, dec] if not keyword_set(radec_star_ref) then radec_star_ref='Unknown' ;*********************** ; get the geodetic lat, E lon, alt in km ;*********************** lat = decparse(latstr) lon = lonparse(lonstr) if not keyword_set(alt) then alt=0. lonlatalt = [lon,lat,alt] if not keyword_set(site_ref) then site_ref='Unknown' if not keyword_set(site_lable) then site_lable=site_name if not keyword_set(observer) then observer='Unknown' if not keyword_set(telescope) then telescope='' if not keyword_set(instrument) then instrument='' ;*********************** ; get the f, g ;*********************** fgh = oc_naiffgh(et_mid, targetcode, radec_star, [0.d,0.d], lonlatalt=lonlatalt) ;*********************** ; make the fits file ;*********************** maxcol = 15 ftcreate,maxcol,n,h,tab space = replicate(' ', n) cr = replicate(string(10b),n) sxaddpar, h, 'TIME_REF', time_ref sxaddpar, h, 'FLUX_REF', flux_ref sxaddpar, h, 'LC_REF', lc_ref sxaddpar, h, 'RA_STAR', rastrf(ra) sxaddpar, h, 'DEC_STAR', decstrf(dec) sxaddpar, h, 'STAR_REF', radec_star_ref sxaddpar, h, 'TARGET', target sxaddpar, h, 'TARGETID', targetcode sxaddpar, h, 'OBSERVER', observer sxaddpar, h, 'SITENAME', site_name sxaddpar, h, 'TELESCOP', telescope sxaddpar, h, 'INSTRUME', instrument sxaddpar, h, 'WAVELEN', wavelen, 'wavelength in micron' sxaddpar, h, 'LONGITUD', lonstr, 'East longitude' sxaddpar, h, 'LATITUDE', latstr, 'Geodetic Latitude' sxaddpar, h, 'ALTITUDE', alt, 'altitude in km' sxaddpar, h, 'SITE_REF', site_ref sxaddpar, h, 'DATE-OBS', date_obs kernels = naif_loadedkernels() for i=0,n_elements(kernels)-1 do begin key = 'KNRL' + string(i+1,fo='(I2.2)') sxaddpar,h,key,kernels[i] end for i=0, n_elements(history)-1 do begin sxaddpar, h, 'HISTORY', history[i] end utc_mid = et2utc(et_mid) ftaddcol,h,tab,'UTC_MID',-strlen(utc_mid[0]), 'A24' ftput, h, tab, 'UTC_MID', 0, utc_mid ftaddcol,h,tab,'SEC_MID',size(0.d,/type), 'D10.3' ftput, h, tab, 'SEC_MID', 0, sec_mid ftaddcol,h,tab,'ITIME',size(0.,/type), 'F8.3' ftput, h, tab, 'ITIME', 0, itime ftaddcol,h,tab,'F_NOM',size(0.d,/type), 'D12.3' ftput, h, tab, 'F_NOM', 0, reform(fgh[0,*]) ftaddcol,h,tab,'G_NOM',size(0.d,/type), 'D12.3' ftput, h, tab, 'G_NOM', 0, reform(fgh[1,*]) ftaddcol,h,tab,'H_NOM',size(0.d,/type), 'D15.3' ftput, h, tab, 'H_NOM', 0, reform(fgh[2,*]) ftaddcol,h,tab,'DF_NOM',size(0.d,/type), 'F12.3' ftput, h, tab, 'DF_NOM', 0, reform(fgh[3,*]) ftaddcol,h,tab,'DG_NOM',size(0.d,/type), 'F12.3' ftput, h, tab, 'DG_NOM', 0, reform(fgh[4,*]) ftaddcol,h,tab,'DH_NOM',size(0.d,/type), 'F12.3' ftput, h, tab, 'DH_NOM', 0, reform(fgh[5,*]) ftaddcol,h,tab,'FLUX',size(0.,/type), 'F12.3' ftput, h, tab, 'FLUX', 0, flux ftaddcol,h,tab,'FLUXERR',size(0.,/type), 'F12.3' ftput, h, tab, 'FLUXERR', 0, flux_err ftaddcol,h,tab,'LC',size(0.,/type), 'F11.5' ftput, h, tab, 'LC', 0, lc ftaddcol,h,tab,'LCERR',size(0.,/type), 'F11.5' ftput, h, tab, 'LCERR', 0, lc_err ftaddcol,h,tab,'QUALFLAG',size(0.,/type), 'I7' ftput, h, tab, 'QUALFLAG', 0, qualflag ftaddcol,h,tab,'EOL',-1 ftput, h, tab, 'EOL', 0, cr ;*********************** ; Write it out ;*********************** fn = outdir + 'lc_fgnom_' + site_name if keyword_set(version) then begin fn = fn + '_v' + strtrim(string(version),2) endif fn = fn + '.fits' writefits, fn, 0 writefits, fn, tab, h, /APPEND end