pro cube_single,pass,def_file_keep,calfactor_temp ;pro cube_single_euv_background_for_Joe,pass,def_file_keep time_initial=pass.time_initial time_middle=pass.time_middle time_final=pass.time_final if time_initial eq 1 then time_initial = 'beginning' else time_initial = 'none' if time_middle eq 1 then time_middle = 'middle' else time_middle = 'none' if time_final eq 1 then time_final = 'end' else time_final = 'none' d=[time_initial,time_middle,time_final] ff=where(d ne 'none') if total(ff) eq -1 then begin print,'No time selected' stop end data_initial=0. data_middle=0. data_final=0. for tt=0,n_elements(ff)-1 do begin ;stop ttt=ff(tt) cspice_ktotal,'all',kernel_count; commented out by ETB on 6/3/2013 trying to generate an executable ;for some reason the IDL virtual environment does not like this call to cspice tempindex=strpos(pass.infile,'.DAT') if total(tempindex) eq -1 then cg_feuv_reader,pass.infile,pp,dd,w0,rof if total(tempindex) ne -1 then open_pds_file,pass.infile,pp,dd,w0,rof integration_time = dd.integration; added by Todd 8/28/2009 rawdataa=rof; added by Todd 8/28/2009 ;turn counts into counts/second if pass.ff_override eq 0 then begin rof = rof/dd.integration endif ;SET UP INTERNAL VARIABLES BASED ON INPUT DATA if pass.target ne 'Ra/Dec' and pass.geometry_reference ne 'Star' then begin pass.ra = -1000.0d pass.dec = -1000.0d endif if strlowcase(dd.channel) eq 'fuv' then instrument = 'CASSINI_UVIS_FUV'; edited by ETB as a test (11/18/2013) if strlowcase(dd.channel) eq 'euv' then instrument = 'CASSINI_UVIS_EUV' if strlowcase(dd.channel) eq 'solar' then instrument = 'CASSINI_UVIS_SOLAR' ;instrument = 'CASSINI_UVIS_SOLAR' if dd.slit_position eq 0 then slit = 'HI' if dd.slit_position eq 1 then slit = 'LO' if dd.slit_position eq 2 then slit = 'OCC' ;stop CORNERS = 1 ;FINALIZE VARIABLES, CREATE STORAGE ARRAYS dims = size(rof,/n_dimensions) index = size(rof) if dims eq 2 then begin readouts = 1 spatial = index(2) spectral = index(1) endif if dims eq 3 then begin readouts = index(3) spatial = index(2) spectral = index(1) endif pass.readouts = readouts pass.spatial = spatial pass.spectral = spectral data = dblarr(spatial,readouts,spectral+58+spectral+spectral); changed from 49 to 52 by Todd 2/13/2009 ; changed from 52 to 53 by Todd 4/1/2009 ; changed from 53 to 54 by Todd 8/28/2009 for integration time to be added to data cube ; changed from 54 to 54 + default_spec by Todd 8/28/2009 to accomodate returning the raw data in the data cube ; changed from 54 to 64 by Todd 8/29/2009 for smeard fovs ; changed from 64 to 74 by Todd 9/2/2009 for smeard longitudes ; changed from 74 to 88 by Todd 11/14/2009 for initial and final solar hour angles (ringsolar) and add in corners for center of ringsolar pixel ; changed from 58 to 59 by Todd 6/14/2012 for ram_sun_angle ; did not incorporate the ram_sun_angle ; added another "+spectral" by Todd on 11/10/2014 for calibration factor; left the 59 in there that was going to be used for ram_sun_angle ; took out the "+spectral" above to put the calibration factor as a variable separate from the structure 6/2/2015; changed from 59 to 58 ;widget_control,pass.text,set_value="Made it to cube single 1 ",/append time = strarr(readouts) data_ra = dblarr(64,readouts) data_dec = dblarr(64,readouts) data_phase = dblarr(64,readouts) data_emission = dblarr(64,readouts) data_incidence = dblarr(64,readouts) data_lat =dblarr(64,readouts) data_lon = dblarr(64,readouts) data_ringplanerad = dblarr(64,readouts) data_scloc = dblarr(64,readouts,3) data_scvel = dblarr(64,readouts,3) data_ra_targ = dblarr(64,readouts) data_dec_targ = dblarr(64,readouts) data_lat_subpt = dblarr(64,readouts) data_lon_subpt = dblarr(64,readouts) data_lat_sunpt =dblarr(64,readouts) data_lon_sunpt = dblarr(64,readouts) data_alt = dblarr(64,readouts) data_phase_targ = dblarr(64,readouts) data_emission_targ =dblarr(64,readouts) data_incidence_targ = dblarr(64,readouts) data_sun_elevation = dblarr(64,readouts) data_earth_elevation = dblarr(64,readouts) data_sunearth = dblarr(64,readouts) data_rayheight =dblarr(64,readouts) data_latocc = dblarr(64,readouts) data_lonocc =dblarr(64,readouts) data_losdist = dblarr(64,readouts) data_ra_full = dblarr(64,readouts,5) data_dec_full = dblarr(64,readouts,5) data_lat_full = dblarr(64,readouts,5) data_lon_full = dblarr(64,readouts,5) data_rrad_full =dblarr(64,readouts,5) data_sc_wrt_plan = dblarr(64,readouts,6) data_state_sun = dblarr(64,readouts,6) data_state_planet = dblarr(64,readouts,6) data_et = dblarr(64,readouts) data_utc = strarr(64,readouts) data_kernels = strarr(kernel_count) ;widget_control,pass.text,set_value="Made it to cube single 2 ",/append data_ramlat = dblarr(64,readouts); added by Todd 2/12/2009 data_ramlon = dblarr(64,readouts); added by Todd 2/12/2009 data_ringsolar_full = dblarr(64,readouts,5); added by Todd 2/12/2009; modified by Todd on 11/14/2009 to add in corners data_ringoccphi= dblarr(64,readouts); added by Todd 4/1/2009 data_integration_time=dblarr(64,readouts); added by Todd 8/28/2009 data_ram_sun_angle = dblarr(64,readouts); added by Todd 6/14/2012 ;**************************************************************************************** ;COMMENTED OUT BY ETB ON 6/3/2013 TRYING TO GENERATE AN EXECUTABLE ;ADD KERNELS TO DATA STRUCTURE kernel_list = strarr(kernel_count) for i = 0, kernel_count do begin cspice_kdata, i, 'ALL', file, type, source, handle, found if ( found ) then begin data_kernels[i] = file endif else begin ; print, 'No kernel found with index: ' + string(i) endelse endfor ;**************************************************************************************** ;CALCULATE MID-INTEGRATION TIME ARRAY timer = strarr(readouts) utc_start = strcompress(string(dd.year_start),/remove_all)+'-'+strcompress(string(dd.doy_start),/remove_all)$ +'/'+strcompress(string(dd.hour_start),/remove_all)+':'+strcompress(string(dd.min_start),/remove_all)+$ ':'+strcompress(string(dd.sec_start),/remove_all) ;utc_start = '2016-353/15:46:57.685884' cspice_str2et, utc_start, etstart etstart = etstart - dd.integration for i=0,readouts-1 do begin temp='' et = etstart + (dd.integration/2.) + (i*dd.integration) ;if i ge 108 then et = et + 290. ;if i ge 726 and i lt 834 then et = et + 530. ;if i ge 834 and i lt 894 then et = et + 530. + 1680. ;if i ge 894 then et = et + 530. + 1680. + 200. + 1000. CSPICE_ET2UTC, et, 'C', 3L, temp time[i] = temp ;if i gt 832 then stop ;data_et[*,i] = et; commented out by Todd on 11/23/2010 endfor if ttt eq 0 then begin for j=0,readouts-1 do begin temp='' et = etstart + (j*dd.integration) ;if j ge 108 then et = et + 290. ;if j ge 726 and j lt 834 then et = et + 530. ;if j ge 834 and j lt 894 then et = et + 530. + 1680. ;if j ge 894 then et = et + 530. + 1680. + 200. + 1000. ;data_et[*,j] = et; added by Todd on 11/23/2010 ;et[j] = etstart + (j*dd.integration); put in by Todd on 4/6/2009 to try new times for geometry CSPICE_ET2UTC, et, 'C', 3L, temp timer[j] = temp endfor endif if ttt eq 1 then begin for j=0,readouts-1 do begin temp='' et = etstart + (dd.integration/2.) + (j*dd.integration) ;if j ge 108 then et = et + 290. ;if j ge 726 and j lt 834 then et = et + 530. ;if j ge 834 and j lt 894 then et = et + 530. + 1680. ;if j ge 894 then et = et + 530. + 1680. + 200. + 1000. ;data_et[*,j] = et; added by Todd on 11/23/2010 ;et[j] = etstart + (j*dd.integration); put in by Todd on 4/6/2009 to try new times for geometry CSPICE_ET2UTC, et, 'C', 3L, temp timer[j] = temp endfor endif if ttt eq 2 then begin for j=0,readouts-1 do begin temp='' et = etstart + (dd.integration) + (j*dd.integration) ;if j ge 108 then et = et + 290. ;if j ge 726 and j lt 834 then et = et + 530. ;if j ge 834 and j lt 894 then et = et + 530. + 1680. ;if j ge 894 then et = et + 530. + 1680. + 200. + 1000. ;data_et[*,j] = et; added by Todd on 11/23/2010 ;et[j] = etstart + (j*dd.integration); put in by Todd on 4/6/2009 to try new times for geometry CSPICE_ET2UTC, et, 'C', 3L, temp timer[j] = temp endfor endif ;LOOP OVER READOUTS, CALL GEOMETER ENGINE for i=0,readouts -1 do begin ;readout loop for j=0,63 do begin ;PIXEL LOOP px = j if px eq 0 then px = -1 ra = pass.ra dec = pass.dec ;widget_control,pass.text,set_value="Made it to cube single 3 ",/append ;the if statement below dealing with solar was put in by ETB on 3/31/2015 to deal with ;solar pointing requests in cube generator. if pass.geometry_reference eq 'Solar' then begin Solar = 'Solar' ra = -500. dec = -500. corners = 0 endif ;the if statement below dealing with star was put in by ETB on 5/19/2015 to deal with ;stellar pointing requests in cube generator. if pass.geometry_reference eq 'Star' then begin radeg = 180D0/!DPI dtor = !DPI/180D0 time_since_epoch = et/3.155D7+8.75 ;PRINT,format='("RA initial = ",f24.16)',staruval.ra ;print,format='("dec initial = ",f24.16)',staruval.dec decstar = pass.dec+pass.mudec*$ time_since_epoch/3.6D6 rastar = pass.ra+COS(pass.dec*!DPI/180D0)*$ pass.mura*time_since_epoch/3.6D6 dist_to_star = 1D0/(pass.parallax*1D-3)*3.086D13 stop CSPICE_RADREC, dist_to_star, rastar*dtor, decstar*dtor, $ starpos CSPICE_SPKEZR, 'CASSINI', et , 'J2000', $ 'NONE', 'SSB', scstate, lt_corr scpos = scstate[0:2] starpos -=scpos Starunit = starpos/CSPICE_VNORM(starpos) CSPICE_RECRAD, starunit, unitdist, rastar,decstar ra = rastar*radeg dec = decstar*radeg endif CG_GEOMETER_ENGINE_6_5, timer[i], instrument, pass.target, phase, emission, incidence, $ ra, dec, lat, lon, ringplanerad, scloc, scvel, ra_targ, dec_targ, $ lat_subpt, lon_subpt, lat_sunpt, lon_sunpt, alt, phase_targ,emission_targ,$ incidence_targ, sun_elevation, earth_elevation, sunearth, ckerror, $ rayheight, latocc, lonocc, losdist, ra_full, dec_full, lat_full, $ lon_full, rrad_full, sc_wrt_plan, state_sun, state_planet, inc_full, $ sc_sun, occpoint_i, ringoccphi, f_peri, rayradius, ramlat, ramlon ,$ ringsolar_full, PIXEL = px, ABCORR = pass.aberration, $ CORNERS = CORNERS, SLIT = SLIT, MOON = MOON, $ SOLAR = SOLAR, pass.geometry_reference ;widget_control,pass.text,set_value="Made it to cube single 4 ",/append if ckerror then begin if pass.ck_checker eq 1 then begin pass.ckcheck=1 goto, CKFAIL endif endif data_ra[j,i] = ra data_dec[j,i] = dec data_phase[j,i] = phase data_emission[j,i] = emission data_incidence[j,i] = incidence data_lat[j,i] = lat data_lon[j,i] = lon data_ringplanerad[j,i] = ringplanerad data_scloc[j,i,*] = scloc data_scvel[j,i,*] = scvel data_ra_targ[j,i] = ra_targ data_dec_targ[j,i] = dec_targ data_lat_subpt[j,i] =lat_subpt data_lon_subpt[j,i] = lon_subpt data_lat_sunpt[j,i] =lat_sunpt data_lon_sunpt[j,i] = lon_sunpt data_alt[j,i] = alt data_phase_targ[j,i] = phase_targ data_emission_targ[j,i] =emission_targ data_incidence_targ[j,i] = incidence_targ data_sun_elevation[j,i] = sun_elevation data_earth_elevation[j,i] = earth_elevation data_sunearth[j,i] = sunearth data_rayheight[j,i] = rayheight data_latocc[j,i] = latocc data_lonocc[j,i] = lonocc data_losdist[j,i] = losdist data_ra_full[j,i,*] = ra_full data_dec_full[j,i,*] = dec_full data_lat_full[j,i,*] = lat_full data_lon_full[j,i,*] = lon_full data_rrad_full[j,i,*] =rrad_full data_sc_wrt_plan[j,i,*] = sc_wrt_plan data_state_sun[j,i,*] = state_sun data_state_planet[j,i,*] = state_planet data_utc[i] = timer[i] data_ramlat[j,i] = ramlat; added by Todd 4/1/2009 data_ramlon[j,i] = ramlon; added by Todd 4/1/2009 data_ringsolar_full[j,i,*] = ringsolar_full; added by Todd 4/1/2009 data_ringoccphi[j,i] = ringoccphi; addedt by Todd 4/1/2009 data_integration_time[j,i]=integration_time; added by Todd 8/28/2009 ;data_ram_sun_angle[j,i] = ram_sun_angle; added by Todd 6/14/2012 endfor ;PIXEL LOOP endfor ;readout loop ;CONSTRUCT BACKPLANES resized = (w0.w_spalr - w0.w_spaul + 1)/w0.w_spabin data_ra = rebin(data_ra[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_dec = rebin(data_dec[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_phase = rebin(data_phase[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_emission = rebin(data_emission[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_incidence = rebin(data_incidence[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lat = rebin(data_lat[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lon = rebin(data_lon[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_ringplanerad = rebin(data_ringplanerad[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_scloc = rebin(data_scloc[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_scvel = rebin(data_scvel[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_ra_targ = rebin(data_ra_targ[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_dec_targ = rebin(data_dec_targ[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lat_subpt = rebin(data_lat_subpt[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lon_subpt = rebin(data_lon_subpt[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lat_sunpt = rebin(data_lat_sunpt[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lon_sunpt = rebin(data_lon_sunpt[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_alt = rebin(data_alt[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_phase_targ = rebin(data_phase_targ[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_emission_targ = rebin(data_emission_targ[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_incidence_targ = rebin(data_incidence_targ[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_sun_elevation = rebin(data_sun_elevation[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_earth_elevation = rebin(data_earth_elevation[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_sunearth = rebin(data_sunearth[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_rayheight = rebin(data_rayheight[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_latocc = rebin( data_latocc[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_lonocc = rebin(data_lonocc[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_losdist = rebin(data_losdist[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_ra_full = rebin(data_ra_full[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,5) data_dec_full = rebin(data_dec_full[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,5) data_lat_full = rebin(data_lat_full[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,5) data_lon_full = rebin(data_lon_full[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,5) data_rrad_full = rebin(data_rrad_full[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,5) data_sc_wrt_plan = rebin(data_sc_wrt_plan[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,6) data_state_sun = rebin(data_state_sun[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,6) data_state_planet = rebin(data_state_planet[w0.w_spaul:w0.w_spalr,*,*],resized,readouts,6) data_et = rebin(data_et[w0.w_spaul:w0.w_spalr,*],resized,readouts) data_ramlat = rebin(data_ramlat[w0.w_spaul:w0.w_spalr,*],resized,readouts); added by Todd 4/1/2009 data_ramlon = rebin(data_ramlon[w0.w_spaul:w0.w_spalr,*],resized,readouts); added by Todd 4/1/2009 data_ringsolar_full = rebin(data_ringsolar_full[w0.w_spaul:w0.w_spalr,*],resized,readouts,5); added by Todd 4/1/2009 data_ringoccphi = rebin(data_ringoccphi[w0.w_spaul:w0.w_spalr,*],resized,readouts); added by Todd 4/1/2009 data_integration_time = rebin(data_integration_time[w0.w_spaul:w0.w_spalr,*],resized,readouts); added by Todd 8/28/2009 ;data_ram_sun_angle = rebin(data_ram_sun_angle[w0.w_spaul:w0.w_spalr,*],resized,readouts); added by Todd 6/14/2012 ;APPLY RTG CORRECTION if pass.rtg eq 1 then begin rtg_factor = pass.rtg_value * w0.w_spabin * w0.w_specbin rof = rof - rtg_factor widget_control,pass.text,set_value='',/append widget_control,pass.text,set_value='RTG Correction Applied',/append widget_control,pass.text,set_value=string(rtg_factor)+' counts/pixel/second',/append widget_control,pass.text,set_value='',/append endif ;THIS CODE PUT IN BY TODD ON 11/7/2014 TO ALLOW FOR SPECTRAL AVERAGE BACKGROUND SUBTRACTION if pass.spec_avg eq 1 then begin temp1 = size(rof) if strlowcase(dd.channel) eq 'fuv' then cg_f_flight_wavelength,wave,w0.w_specbin if strlowcase(dd.channel) eq 'euv' then cg_e_flight_wavelength,wave,w0.w_specbin d=where(wave ge pass.lower_wavelength and wave le pass.upper_wavelength) if temp1(0) eq 2 then begin for spatial_loop=0,temp1(2)-1 do begin rof(*,spatial_loop)=rof(*,spatial_loop) - mean(rof(d,spatial_loop)) end endif else begin for spatial_loop=0,temp1(2)-1 do begin for record_loop=0,temp1(3)-1 do begin rof(*,spatial_loop,record_loop)=rof(*,spatial_loop,record_loop) - mean(rof(d,spatial_loop,record_loop)) end end endelse widget_control,pass.text,set_value='',/append widget_control,pass.text,set_value='Spectral Average Background Subtracted',/append widget_control,pass.text,set_value='Average from ' + string(pass.lower_wavelength) + ' -' + strcompress(string(pass.upper_wavelength)) + ' Angstroms',/append;string(rtg_factor)+' counts/pixel/second',/append widget_control,pass.text,set_value='',/append endif ;THIS CODE PUT IN BY TODD ON 6/30/2009 IN ORDER TO DEAL WITH EUV BACKGROUND SUBTRACTION FOR JOE ; if strlowcase(dd.channel) eq 'euv' then begin ; temp1=size(rof) ; cg_e_Flight_Wavelength,ewave,w0.w_specbin ; ; d=where(ewave ge 750. and ewave le 800.) ; ;d=where(ewave ge 1040. and ewave le 1070.) ; if temp1(0) eq 2 then begin ; for spatial_loop=0,temp1(2) -1 do begin ; rof(*,spatial_loop)=rof(*,spatial_loop); - mean(rof(d,spatial_loop)) ; end ; endif else begin ; for spatial_loop=0,temp1(2)-1 do begin ; for record_loop=0,temp1(3)-1 do begin ; rof(*,spatial_loop,record_loop)=rof(*,spatial_loop,record_loop); - mean(rof(d,spatial_loop,record_loop)) ; end ; end ; endelse ; end ;END OF CODE PUT IN BY TODD TO DEAL WITH EUV ;BEGIN PROCESSING ROUTINES (CALIBRATION, RED PATCH, + FLATFIELD) if pass.ff_override eq 0 then begin ;Catch for possible RAW data output index = size(rof) rof_1 = fltarr(index(1),index(2),index(3)) rawdata=fltarr(index(1),index(2),index(3)) if index(0) eq 2 then rawdata(*,*,0)=rawdataa; put in by Todd 8/28/2009 to have raw data in the data cube if index(0) eq 3 then rawdata=rawdataa; put in by Todd 8/28/2009 to have raw data in the data cube if pass.ff_selector eq 0 then begin ;APPLY FULL FLATFIELD CORRECTION bin_definition = [w0.w_specbin, w0.w_spabin] input_spectrum = 1 if dd.slit_position eq 0 then slit_width = 2 if dd.slit_position eq 1 then slit_width = 1 if dd.slit_position eq 2 then slit_width = 0 window_definition = [w0.w_specul,w0.w_spaul, w0.w_speclr, w0.w_spalr] sctime = dd.sctime_sec_start if strlowcase(dd.channel) eq 'fuv' then begin ;FUV calibration First ;GREG HOLSCLAW ULTIMATE CAL ROUTINE cg_F_Flight_Wavelength,f_wavelength,w0.w_specbin ;cg_Get_FUV_2010_Lab_Calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,window_definition,bin_definition,sctime,noff=0,noevolve=0,def_file_keep wdir = def_file_keep + 'uvis_cal_and_ff_modifiers' + path_sep() channel_ = dd.channel cg_get_uvis_2015_calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,window_definition,$ bin_definition,sctime,evil_pixel_constant,noff=noff,keep_evil=keep_evil,unresolved=unresolved,channel=channel_, wdir ;stop ; cg_interpolate_nans2,f_calibration,flf1 ; ; f_calibration = flf1 ; ; ;Apply ; ; index = size(rof) ; ; for j=0,index(3)-1 do begin ; rof_1[*,*,j] = float(rof[*,*,j]) * f_calibration ; endfor ;Apply index = size(rof) if index(0) eq 3 then begin ;Line added by ETB 3_26_2010 for j=0,index(3)-1 do begin temp = float(rof[*,*,j]) * f_calibration ; GMH edit, 2007-05-03 cg_interpolate_nans2,temp,tempi ; GMH edit, 2007-05-03 rof_1[*,*,j] = tempi ; GMH edit, 2007-05-03 ;stop endfor endif if index(0) eq 2 then begin ;Line added by ETB 3_26_2010 temp = float(rof[*,*]) * f_calibration ; GMH edit, 2007-05-03 cg_interpolate_nans2,temp,tempi ; GMH edit, 2007-05-03 rof_1[*,*] = tempi ; GMH edit, 2007-05-03 endif endif ;stop if strlowcase(dd.channel) eq 'euv' then begin ;FULL PROCESSING OF EUV DATA ;1999 calibration file cg_e_Flight_Wavelength,e_wavelength,w0.w_specbin ;cg_Get_EUV_2010_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,window_definition,bin_definition,sctime,noff=noff,def_file_keep index = size(rof) wdir = def_file_keep + 'uvis_cal_and_ff_modifiers' + path_sep() channel_ = dd.channel ;stop cg_get_uvis_2015_calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,window_definition,$ bin_definition,sctime,evil_pixel_constant,noff=noff,keep_evil=keep_evil,unresolved=unresolved,channel=channel_, wdir ;****************************************************************************************************** ;EDITED BY TODD BRADLEY 2/22/2012 IN ORDER TO DEAL WITH EUV FILES THAT CONSIST OF ONLY ONE DATA RECORD if index(0) eq 3 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof[*,*,j]) * e_calibration endfor endif if index(0) eq 2 then begin rof_1[*,*] = float(rof[*,*]) * e_calibration endif ;stop ;****************************************************************************************************** endif endif else begin ;ala carte FLATFIELD CORRECTION begin if strlowcase(dd.channel) eq 'fuv' then begin ;FUV calibration First ;read the correct calibration file cg_F_Flight_Wavelength,f_wavelength,w0.w_specbin if pass.cal_choice eq 0 then begin ;1997 calibration cg_Get_FUV_97_Lab_Calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,bin_definition end if pass.cal_choice eq 1 then begin ;1999 calibration cg_Get_FUV_99_Lab_Calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,bin_definition f_calibration = f_calibration * 0.91 end if pass.cal_choice eq 2 then begin ;2003 calibration cg_Get_FUV_03_Lab_Calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,window_definition,bin_definition end if pass.cal_choice eq 3 then begin ;2004 calibration cg_Get_FUV_04_Lab_Calibration,f_wavelength,f_calibration,f_calibration_error,slit_width,input_spectrum,window_definition,bin_definition end if pass.cal_choice eq 4 then begin pass.redpatch = 0 endif ;read in the red patch, if chosen if pass.redpatch eq 1 then begin if pass.ff_choice eq 0 then begin cg_get_fuv_red_patch,fuv_corr, w0, 1 endif else begin cg_get_fuv_red_patch,fuv_corr, w0, 0 endelse endif ;read in the flatfield if pass.ff_choice eq 0 then begin ;AJS flatfield restore,'uvis_flatfield_postburn.dat' flatfield_fuv_postburn = flf[*,*,3] if pass.nan_choice eq 0 then begin cg_bin_win_flatfield,0,flatfield_fuv_postburn,w0,bin_win_flatfield flf_resized = bin_win_flatfield * 1.05 ;With Correction Factor endif if pass.nan_choice eq 1 then begin cg_interpolate_nans,flatfield_fuv_postburn,flf1 flf_new= flf1 cg_bin_win_flatfield,0,flf_new,w0,bin_win_flatfield flf_resized = bin_win_flatfield * 1.05 ;With Correction Factor endif endif if pass.ff_choice eq 1 then begin ;IS flatfield cg_read_ajs_flf,flag,flf,flf_d flatfield_fuv_postburn = flf[*,*,3] cg_bin_win_flatfield,0,flatfield_fuv_postburn,w0,bin_win_flatfield flf_resized = bin_win_flatfield * 1.37 ;With Correction Factor endif ;apply the above index = size(rof) if pass.cal_choice ne 4 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof[*,*,j]) * f_calibration endfor endif else begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof[*,*,j]) endfor endelse if pass.redpatch eq 1 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof_1[*,*,j]) * fuv_corr endfor endif if pass.nan_choice ne 2 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof_1[*,*,j]) * flf_resized endfor endif endif ;end of fuv ala carte loop if strlowcase(dd.channel) eq 'euv' then begin ;euv ala carte loop ;read the correct calibration file cg_e_Flight_Wavelength,e_wavelength,w0.w_specbin if pass.cal_choice eq 0 then begin ;1997 calibration cg_Get_EUV_97_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,bin_definition end if pass.cal_choice eq 1 then begin ;1999 calibration cg_Get_EUV_99_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,bin_definition end if pass.cal_choice eq 2 then begin ;2003 calibration cg_Get_EUV_03_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,window_definition,bin_definition end ;read in the flatfield if pass.ff_choice ne 2 then begin ;AJS flatfield restore,'uvis_flatfield_postburn.dat' ; cg_interpolate_nans,flatfield_euv_postburn,flf1 flf_new= flatfield_euv_postburn flf_new[*,0:1] = 0.0 flf_new[*,61:63] = 0.0 cg_bin_win_flatfield,0,flf_new,w0,bin_win_flatfield flf_resized = bin_win_flatfield endif ;apply if pass.cal_choice ne 4 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof[*,*,j]) * e_calibration endfor endif else begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof[*,*,j]) endfor endelse if pass.nan_choice ne 2 then begin for j=0,index(3)-1 do begin rof_1[*,*,j] = float(rof_1[*,*,j]) * flf_resized endfor endif endif ;end of euv ala carte loop endelse ;end ala carte processing endif else begin ;if OUtputing just raw data rof_1 = rof endelse if instrument eq 'CASSINI_UVIS_FUV' then calfactor_temp = f_calibration if instrument eq 'CASSINI_UVIS_EUV' then calfactor_temp = e_calibration if instrument eq 'CASSINI_UVIS_FUV' then calerror_temp = f_calibration_error if instrument eq 'CASSINI_UVIS_EUV' then calerror_temp = e_calibration_error ;ASSEMBLE THE CUBE ;PUTTING IN THE IF...THEN STATEMENTS BASED ON THE SIZE OF ROF (TEMP1) WAS DONE BY ETB 3_26_2010 temp1=size(rof) if temp1[0] eq 3 then begin for i=0,index(1) -1 do begin data[*,*,i] = double(rof_1[i,*,*]) data[*,*,i+ spectral + 59]=rawdata[i,*,*]; added by Todd on 8/28/2009 to put the raw data into the cube ;data[*,*,i + spectral + spectral + 59] = calfactor_temp[i,*]; commented out on 5/28/2015 by ETB after Amanda Hendrix encountered a problem with this. endfor endif if temp1[0] eq 2 then begin for i=0,index(1) -1 do begin data[*,*,i] = double(rof_1[i,*]) data[*,*,i+ spectral + 59]=rawdata[i,*]; added by Todd on 8/28/2009 to put the raw data into the cube ;data[*,*,i + spectral + spectral + 59] = calfactor_temp[i,*]; commented out on 5/28/2015 by ETB after Amanda Hendrix encountered a problem with this. endfor endif ;stop ;SPATIALLY REBINNED FULL GEOMETRY FILES base_plane = index(1) data[*,*,base_plane] = data_ra_full(*,*,0) data[*,*,base_plane+1] = data_ra_full(*,*,1) data[*,*,base_plane+2] = data_ra_full(*,*,2) data[*,*,base_plane+3] = data_ra_full(*,*,3) data[*,*,base_plane+4] = data_ra_full(*,*,4) data[*,*,base_plane+5] = data_dec_full(*,*,0) data[*,*,base_plane+6] = data_dec_full(*,*,1) data[*,*,base_plane+7] = data_dec_full(*,*,2) data[*,*,base_plane+8] = data_dec_full(*,*,3) data[*,*,base_plane+9] = data_dec_full(*,*,4) data[*,*,base_plane+10] = data_lat_full(*,*,0) data[*,*,base_plane+11] = data_lat_full(*,*,1) data[*,*,base_plane+12] = data_lat_full(*,*,2) data[*,*,base_plane+13] = data_lat_full(*,*,3) data[*,*,base_plane+14] = data_lat_full(*,*,4) data[*,*,base_plane+15] = data_lon_full(*,*,0) data[*,*,base_plane+16] = data_lon_full(*,*,1) data[*,*,base_plane+17] = data_lon_full(*,*,2) data[*,*,base_plane+18] = data_lon_full(*,*,3) data[*,*,base_plane+19] = data_lon_full(*,*,4) data[*,*,base_plane+20] = data_incidence(*,*) data[*,*,base_plane+21] = data_emission(*,*) data[*,*,base_plane+22] = data_phase(*,*) data[*,*,base_plane+23] = data_rayheight(*,*) data[*,*,base_plane+24] = data_latocc(*,*) data[*,*,base_plane+25] = data_lonocc(*,*) data[*,*,base_plane+26] = data_losdist(*,*) data[*,*,base_plane+27] = data_lon_subpt data[*,*,base_plane+28] = data_lat_subpt data[*,*,base_plane+29] = data_lon_sunpt data[*,*,base_plane+30] = data_lat_sunpt data[*,*,base_plane+31] = data_alt data[*,*,base_plane+32] = data_ra_targ data[*,*,base_plane+33] = data_dec_targ data[*,*,base_plane+34] = data_phase_targ data[*,*,base_plane+35] = data_incidence_targ data[*,*,base_plane+36] = data_emission_targ data[*,*,base_plane+37] = data_sc_wrt_plan[*,*,0] data[*,*,base_plane+38] = data_sc_wrt_plan[*,*,1] data[*,*,base_plane+39] = data_sc_wrt_plan[*,*,2] data[*,*,base_plane+40] = data_sc_wrt_plan[*,*,3] data[*,*,base_plane+41] = data_sc_wrt_plan[*,*,4] data[*,*,base_plane+42] = data_sc_wrt_plan[*,*,5] data[*,*,base_plane+43] = data_et[*,*] data[*,*,base_plane+44] = data_rrad_full[*,*,0] data[*,*,base_plane+45] = data_rrad_full[*,*,1] data[*,*,base_plane+46] = data_rrad_full[*,*,2] data[*,*,base_plane+47] = data_rrad_full[*,*,3] data[*,*,base_plane+48] = data_rrad_full[*,*,4] data[*,*,base_plane+49] = data_ramlat[*,*]; added by Todd 4/1/2009 data[*,*,base_plane+50] = data_ramlon[*,*]; added by Todd 4/1/2009 data[*,*,base_plane+51] = data_ringsolar_full[*,*,0]; added by Todd 2/12/2009 data[*,*,base_plane+52] = data_ringsolar_full[*,*,1] data[*,*,base_plane+53] = data_ringsolar_full[*,*,2] data[*,*,base_plane+54] = data_ringsolar_full[*,*,3] data[*,*,base_plane+55] = data_ringsolar_full[*,*,4] data[*,*,base_plane+56] = data_ringoccphi[*,*]; added by Todd 4/1/2009 data[*,*,base_plane+57] = data_integration_time[*,*]; added by Todd 8/28/2009 ;data[*,*,base_plane+58] = data_ram_sun_angle[*,*]; added by Todd 6/14/2012 ;OUTPUT IMAGE CUBE if ttt eq 0 then data_initial=data if ttt eq 1 then data_middle=data if ttt eq 2 then data_final=data if ttt eq 0 then utc_initial=data_utc if ttt eq 1 then utc_middle=data_utc if ttt eq 2 then utc_final=data_utc endfor ; end of tt loop over initial and final times in order to generate smeared fovs Todd 8/29/2009 ;NOTE VARIABLES version = 'Cube Generator Version 11.2014' if pass.rtg eq 1 then background = 'Background: RTG Background Subtraction; ' + strcompress(string(pass.rtg_value)) + ' counts/second/pixel' if pass.spec_avg eq 1 then background = 'Background: Spectral Average Background Subtraction;' + strcompress(string(pass.lower_wavelength)) + ' -' + $ strcompress(string(pass.upper_wavelength)) + ' Angstroms' if pass.rtg eq 0 and pass.spec_avg eq 0 then background = 'No Background Selected' if pass.ff_selector eq 0 then begin calibration_version = 'Ultimate Greg Holsclaw Time Varying Calibration' if instrument eq 'CASSINI_UVIS_FUV' then redpatch_selection = 'FUV Red Patch Applied' flatfield_version = 'Ultimate Greg Holsclaw Time Varying Flat Field' nan_selection = 'NaN Interpolation' end if pass.ff_selector eq 1 then begin if pass.cal_choice eq 0 then calibration_version = 'Calibration = 1997' if pass.cal_choice eq 1 then calibration_version = 'Calibration = 1999' if pass.cal_choice eq 2 then calibration_version = 'Calibration = 2003' if pass.cal_choice eq 3 then calibration_version = 'Calibration = 2004' if pass.cal_choice eq 4 then calibration_version = 'No Calibration Applied' if pass.redpatch eq 0 then redpatch_selection = 'FUV Red Patch Not Applied' if pass.redpatch eq 1 then redpatch_selection = 'FUV Red Patch Applied' if pass.ff_choice eq 0 then flatfield_version = 'Andrew Steffl Flat Field Applied' if pass.ff_choice eq 1 then flatfield_version = 'Ian Stewart Flat Field Applied' if pass.ff_choice eq 2 then flatfield_version = 'No Flat Field Applied' if pass.nan_choice eq 0 then nan_selection = 'No NaN Interpolation' if pass.nan_choice eq 1 then nan_selection = 'NaN Interpolation Performed' endif target_selection = 'Target = ' + pass.target if instrument eq 'CASSINI_UVIS_FUV' then note = [version,$ target_selection,$ background,$ calibration_version, $ redpatch_selection, $ flatfield_version,$ nan_selection] if instrument eq 'CASSINI_UVIS_EUV' then note = [version,$ target_selection,$ background,$ calibration_version, $ flatfield_version,$ nan_selection] if pass.outform eq 'BINARY' then begin name_extract = strmid(pass.outfile,3,1,/reverse_offset) if name_extract eq '.' then begin full_outfile_name = pass.outfile endif else begin full_outfile_name = pass.outfile+'.bin' endelse cg_write_binary, string(full_outfile_name), data_initial,data_middle,data_final,time_initial,time_middle,time_final,calfactor_temp,note,calerror_temp widget_control,pass.text,set_value='Output to Raw Binary',/append endif if pass.outform eq 'ENVI' then begin name_extract = strmid(pass.outfile,3,1,/reverse_offset) if name_extract eq '.' then begin full_outfile_name = pass.outfile endif else begin full_outfile_name = pass.outfile+'.img' endelse cg_write_envi, string(full_outfile_name), pass.spatial, pass.readouts, pass.spectral,dd,w0,data_initial,data_middle,data_final,time_initial,time_middle,time_final,calfactor_temp,note,calerror_temp widget_control,pass.text,set_value='Output to ENVI format',/append endif if pass.outform eq 'IDL_SAV' then begin name_extract = strmid(pass.outfile,3,1,/reverse_offset) if name_extract eq '.' then begin full_outfile_name = pass.outfile endif else begin full_outfile_name = pass.outfile + '.sav' endelse if pass.sav_version eq 0 then begin cg_write_save_orig, string(full_outfile_name),data_initial,data_middle,data_final,utc_initial,utc_middle,utc_final,data_kernels,time_initial,time_middle,time_final,note endif else begin cg_write_save_new, string(full_outfile_name),data_initial,data_middle,data_final,utc_initial,utc_middle,utc_final,data_kernels, w0 , spatial, spectral, readouts,time_initial,time_middle,time_final,calfactor_temp,note,calerror_temp endelse widget_control,pass.text,set_value='Output to IDL Save file',/append endif if pass.outform eq 'FITS' then begin name_extract = strmid(pass.outfile,3,1,/reverse_offset) if name_extract eq '.' then begin full_outfile_name = pass.outfile endif else begin full_outfile_name = pass.outfile+'.fits' endelse cg_write_save_new, string(full_outfile_name), data_initial, data_middle, $ data_final, utc_initial, utc_middle, utc_final, data_kernels, w0, spatial, $ spectral, readouts, time_initial, time_middle, time_final, calfactor_temp, $ note, calerror_temp, /FITS widget_control,pass.text,set_value='Output to FITS file',/append endif if pass.ckcheck eq 0 then goto, jump CKFAIL: widget_control, pass.text,set_value= '**** CK ERROR ****' widget_control, pass.text, set_value= '',/append widget_control, pass.text, set_value= 'Check that you loaded the correct C-Kernels and try again',/append JUMP: return end