;+ ; :Description: ; Extract CoMP Intensity image from closest to line center. ; ; :Params: ; date_dir day of year to process, in YYYYMMDD format ; wave_type name of line for set of wavelengths ; ; ; :Author: sitongia ;- pro extract_intensity, date_dir, wave_type common comp_paths, bias_dir, flat_dir, mask_dir, inventory_basedir, binary_dir, $ defered_file, hot_file, $ ldm_basedir, usb_basedir, raw_synoptic_basedir, raw_usb_basedir, process_synoptic_basedir, process_usb_basedir, $ archive_dir, movie_dir, fullres_dir, log_dir common comp_constants, nx, ny, $ center1074, center1079, center1083, $ stokes, n_stokes, $ debug, logFileUnit ;; ADDED BY JAMES MICHAELIS ;; ADD COMMON BLOCKS FOR EACH LOGGER common logBlock_artifact, Counter_1, NameRegistry_1, IDRegistry_1, LUN_1 common logBlock_process, Counter_2, NameRegistry_2, IDRegistry_2, LUN_2 common logBlock_activity, Counter_3, NameRegistry_3, IDRegistry_3, LUN_3 common logBlock_observation, Counter_4, NameRegistry_4, IDRegistry_4, LUN_4 common logBlock_entity, Counter_5, NameRegistry_5, IDRegistry_5, LUN_5 common logBlock_dataset, Counter_6, NameRegistry_6, IDRegistry_6, LUN_6 common logBlock_qualityAssertion, Counter_7, NameRegistry_7, IDRegistry_7, LUN_7 common logBlock_qualityEvidence, Counter_8, NameRegistry_8, IDRegistry_8, LUN_8 common logBlock_fitsHeader, Counter_9, LUN_9 ;; END ;; ADDED BY JAMES MICHAELIS ;; RESTORE VARIABLE STATE FROM PRIOR EXECUTION (allows logBlock values to be carried over) Restore,'CoMP_commonBlocks.sav' ;; END COMPILE_OPT IDL2 ; Configure comp_paths comp_initialize, date_dir printf, logFileUnit, 'extract_intensity' ; Check keywords uselist = 0 if n_elements(list_file) eq 1 then uselist = 1 process_dir = process_usb_basedir + date_dir cd, process_dir ; Line center case wave_type of '1074' : begin lineCenter = center1074 ScaleMax = 20.0 gifMin = 0.0 gifMax = 5.0 end '1079' : begin lineCenter = center1079 ScaleMax = 20.0 gifMin = 0 gifMax = 3.5 end '1083' : begin lineCenter = center1083 ScaleMax = 200000.0 gifMin = 0 gifMax = 200000.0 end endcase ; Read in the field mask fits_read, mask_dir+'fieldmask1.fits', fieldmask1 fits_read, mask_dir+'fieldmask2.fits', fieldmask2 ; The FITS image files files = file_search('*.comp.' + wave_type + '.fts.gz', COUNT=count) for filesIndex = 0L, count-1 do begin if debug eq 1 then print, "File " + files[filesIndex] + " " + systime() fits_read, files[filesIndex], data, primary_header, exten_no=0 fits_read, files[filesIndex], data, header, exten_no=1 extract_intensity_cube, files[filesIndex], images, waves ; Determine index of wavelength closest to line center waveDiff = abs(waves - lineCenter) lineCenterIndex = where(waveDiff eq min(waveDiff)) lineCenterIndex = lineCenterIndex[0] if debug eq 1 then print, "Using wavelength ", waves[lineCenterIndex] ; Intensity simple by extracting image near line center intensity = images[*, *, lineCenterIndex] ; Clip ;intensity = 0 > intensity < ScaleMax ; larger of 0 and image, then smaller of image and ScaleMax. ; Set the processing level sxaddpar,primary_header,'LEVEL ','L1' ; Write files sxaddpar, primary_header, 'METHOD ', 'EXTRACT', ' Method used: extract filtergram at line center' fits_write, strmid(files[filesIndex],0,15) + '.comp.' + wave_type+'.intensity.fts', intensity, primary_header endfor ; Compress files if debug eq 1 then print, "Compressing FITS files." spawn, 'gzip -f *.comp.' + wave_type + '.intensity.fts' ; Make GIF files from Intensity files = file_search('*.comp.' + wave_type + '.intensity.fts.gz', COUNT=count) if debug eq 1 then print, "Make GIFs" for filesIndex = 0L, count-1 do begin ; Make GIF from I file make_gif, files[filesIndex], nx, 'Intensity', wave_type, gifMin, gifMax ;; ADDED BY JAMES MICHAELIS ;; ADD LOG STATEMENTS newNameFITS = strmid(files[filesIndex],0,15) + '.comp.' + wave_type+'.intensity.fts' newNameGIF = strmid(files[filesIndex],0,15) + '.comp.' + wave_type+'.intensity.gif' newName = strmid(files[filesIndex],0,15)+'.comp.'+wave_type+'.fts.gz' ID_Process_1 = log_process('Extract Intensity','Extract CoMP Intensity image from closest to line center.', $ 'extract_intensity.pro','https://subversion.ucar.edu/HAO/MLSO/CoMP/Pipeline/extract_intensity.pro','3798','Interactive Data Language (IDL)','Steve Tomczyk',[loggedID('artifact',name)],[],[]) ID_Artifact_1 = log_artifact(newNameFITS,'','FITS','http://path/to/FITS/' + newNameFITS,[],newNameFITS) ID_Artifact_2 = log_artifact(newNameGIF,'','GIF','http://path/to/GIF/' + newNameGIF,[],newNameGIF) ID_Entity_1 = log_entity(newName,'CoMP intensity record processed by extract intensity routine',[ID_Dataset_1],[ID_Artifact_1, ID_Artifact_2]) ID_FitsHeader_1 = log_fitsheader(newNameFITS, [ID_Artifact_1]) print, ID_Entity_1 ID_Observation_1 = log_observation('CoMP intensity observation','CoMP intensity observation','StokesIntensityObservation','2011-06-29T21:49:38','2011-06-29T21:49:38','StokesParameterI','Stokes Intensity','SunCorona','Sun Corona',[ID_Entity_1]) ;; END endfor printf, logFileUnit, "done ", systime() free_lun, logFileUnit if debug eq 1 then print, "Done all ", systime() ;; ADDED BY JAMES MICHAELIS stop_logger ; closes LUNs for each log Save, /ALL, filename='CoMP_commonBlocks.sav' ; save all variables (including common blocks) to file to be opened later. this preserves logging blocks for upcoming IDL scripts ;; END end ; Main program for testing extract_intensity, '20110504', '1083' end