pro get_skyrad60s_sirs, curdate,site,datastream,input_flag common skyrad60s_sirs_data, base_time, time_offset, $ psp,pir,irt,uvb,psps,pirs,nip,lat,lon,alt ; ; Pieces to use to make the directory and filename ; year=fix(strmid(curdate,0,4)) month=fix(strmid(curdate,4,2)) check_date=year+month/12. if input_flag eq 'one' then begin if site eq 'twpc1' then begin armdatadir='/data/mace/arm_data/twp/Manus_C1/' datastream='twpskyrad60sC1.b1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twpskyrad60sC2.b2' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsaskyrad60sC1.b1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' if check_date ge (2001.0 + 4./12.) then begin datastream='sgpsirs60sC1.a1' endif else begin datastream='sgpsirsC1.a1' endelse endif armfile=armdatadir+datastream+'/'+datastream+'.'+curdate+'*.cd*' endif else if input_flag eq 'eos' then begin if site eq 'twpc1' then begin armdatadir='/data/mace/arm_data/twp/Manus_C1/' eosfilename='twpC1.eos_val_mace.c1' datastream='twpskyrad60sC1.b2' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='twpskyrad60sC2.b2' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='nsaskyrad60sC1.b1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgpsirsC1.a1' endif armfile=armdatadir+eosfilename+'/'+eosfilename+'.'+curdate+'*.cd*' endif ; ; Unzip the data files ; unix_command='gunzip -fq '+armfile spawn,unix_command ; ; Get a list of the matching filenames ; print, 'filename ',armfile files=findfile(armfile,count=count) print, 'files ',files print, 'count ',count ; ; Process files ; j=-1 ;counts number of cdf files for i=0,count-1 do begin ;do for all the matching files in the directory ; ; Don't try to process any gif files that may be in the directory ; if strpos(files[i],'gif') eq -1 and $ strpos(files[i],'png') eq -1 then begin j=j+1 ; ; Open the netcdf file ; cdfid=ncdf_open(files[i]) ; ; Get the dimension id's ; time_did=ncdf_dimid(cdfid,'time') ; ; Get the variable id's ; base_time_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') psp_id=ncdf_varid(cdfid,'down_short_hemisp') ;variable name for twp and nsa before 4-1-2001 if psp_id eq -1 then psp_id=ncdf_varid(cdfid,'psp1_mean') ;variable name for twp and nsa in the eos files if psp_id eq -1 then psp_id=ncdf_varid(cdfid,'down_psp1_mean') pir_id=ncdf_varid(cdfid,'down_long_hemisp') ;variable name for sgp after 4-1-2001 if pir_id eq -1 then pir_id=ncdf_varid(cdfid,'down_long_hemisp_shaded') ;variable name for nsa and twp before 4-1-2001 if pir_id eq -1 then pir_id=ncdf_varid(cdfid,'pirs_mean') ;variable name for twp and nsa in the eos files if pir_id eq -1 then pir_id=ncdf_varid(cdfid,'down_pir1_mean') irt_id=ncdf_varid(cdfid,'irt1_mean') ;variable has a different name after 4-1-2001 ;both sky_ir_temp variables in skyrad and mwr have then same name. ;changed to skyrad_ir_temp for the eos files. if irt_id eq -1 then irt_id=ncdf_varid(cdfid,'skyrad_ir_temp') if irt_id eq -1 then irt_id=ncdf_varid(cdfid,'sky_ir_temp') uvb_id=ncdf_varid(cdfid,'uvb_mean') ;variable has a different name after 4-1-2001 if uvb_id eq -1 then uvb_id=ncdf_varid(cdfid,'down_uvb') psps_id=ncdf_varid(cdfid,'down_short_diffuse_hemisp') ;variable name for nsa and twp before 4-1-2001 if psps_id eq -1 then psps_id=ncdf_varid(cdfid,'psps_mean') pirs_id=ncdf_varid(cdfid,'pir1_mean') if pirs_id eq -1 then pirs_id=ncdf_varid(cdfid,'down_long_hemisp_unshaded') nip_id=ncdf_varid(cdfid,'short_direct_normal') ;variable name for nsa and twp before 4-1-2001 if nip_id eq -1 then nip_id=ncdf_varid(cdfid,'nip_mean') lat_id=ncdf_varid(cdfid,'lat') lon_id=ncdf_varid(cdfid,'lon') alt_id=ncdf_varid(cdfid,'alt') ; ; Get the data ; if base_time_id ne -1 then ncdf_varget, cdfid, base_time_id, base_time if time_offset_id ne -1 then ncdf_varget, cdfid, time_offset_id, time_offset if psp_id ne -1 then ncdf_varget, cdfid, psp_id, psp if pir_id ne -1 then ncdf_varget, cdfid, pir_id, pir if irt_id ne -1 then ncdf_varget, cdfid, irt_id, irt if uvb_id ne -1 then ncdf_varget, cdfid, uvb_id, uvb if psps_id ne -1 then ncdf_varget, cdfid, psps_id, psps if pirs_id ne -1 then ncdf_varget, cdfid, pirs_id, pirs if nip_id ne -1 then ncdf_varget, cdfid, nip_id, nip if lat_id ne -1 then ncdf_varget, cdfid, lat_id, lat if lon_id ne -1 then ncdf_varget, cdfid, lon_id, lon if alt_id ne -1 then ncdf_varget, cdfid, alt_id, alt ; ; Combine the data into big arrays ; if j eq 0 then begin ;if it is the first file if time_offset_id ne -1 then com_btto=base_time+time_offset if psp_id ne -1 then com_psp=psp if pir_id ne -1 then com_pir=pir if irt_id ne -1 then com_irt=irt if uvb_id ne -1 then com_uvb=uvb if psps_id ne -1 then com_psps=psps if pirs_id ne -1 then com_pirs=pirs if nip_id ne -1 then com_nip=nip endif else begin ;if it is not the first file if time_offset_id ne -1 then com_btto=[com_btto,base_time+time_offset] if psp_id ne -1 then com_psp=[com_psp,psp] if pir_id ne -1 then com_pir=[com_pir,pir] if irt_id ne -1 then com_irt=[com_irt,irt] if uvb_id ne -1 then com_uvb=[com_uvb,uvb] if psps_id ne -1 then com_psps=[com_psps,psps] if pirs_id ne -1 then com_pirs=[com_pirs,pirs] if nip_id ne -1 then com_nip=[com_nip,nip] endelse ;end of if it is the first file ; ; Close the netcdf file ; ncdf_close,cdfid endif ;only process gif files endfor ;loop through number of matching file names ; ; Skip the rest if there are no files ; if j lt 0 then print, 'found no files' if j lt 0 then exit ; ; Skip the rest if there are no variables ; (irt_id is from mwr for nsa so don't use it ; in this if statement) if psp_id eq -1 and pir_id eq -1 $ and uvb_id eq -1 and psps_id eq -1 and pirs_id eq -1 $ and nip_id eq -1 $ then begin if input_flag eq 'eos' then begin openw,15,'/data/mace4/arm_data/eos/eos_image_name.dat' printf,15,0 close,15 endif print, 'found no variables' ; ; Zip up the data files ; unix_command='gzip -fq '+armfile ;zip the data files spawn,unix_command ;unzip any gif files unintentionally zipped unix_command='gunzip -fq *'+strcompress(year,/remove_all)+'*gif.gz' spawn,unix_command unix_command='chmod 664 '+armfile ;change permissions spawn,unix_command unix_command='chgrp met-mace '+armfile ;change group spawn,unix_command exit endif ; ; Create the final arrays ; if base_time_id ne -1 then base_time=com_btto[0] if time_offset_id ne -1 then time_offset=com_btto-com_btto[0] if psp_id ne -1 then psp=com_psp if pir_id ne -1 then pir=com_pir if irt_id ne -1 then irt=com_irt if uvb_id ne -1 then uvb=com_uvb if psps_id ne -1 then psps=com_psps if pirs_id ne -1 then pirs=com_pirs if nip_id ne -1 then nip=com_nip ; ; Zip up the data files ; unix_command='gzip -fq '+armfile ;zip the data files spawn,unix_command ;unzip any gif files unintentionally zipped unix_command='gunzip -fq *'+strcompress(year,/remove_all)+'*gif.gz' spawn,unix_command unix_command='chmod 664 '+armfile ;change permissions spawn,unix_command unix_command='chgrp met-mace '+armfile ;change group spawn,unix_command return end