;+ ; NAME: ; xhcs ; PURPOSE: ; Read a file that lists a set of Nick's WSO or NSO files. ; Run X's code on them, and create source surface maps ; CALLING SEQUENCE: PRO xhcs, obs, destination=destination, list=list, source=source, $ remote_prefix=remote_prefix, local_prefix=local_prefix, gzip=gzip, $ rss=rss, rcp=rcp ; INPUTS: ; obs scalar; type: character; default: 'wso' ; indentifies origin of magnetic field data ; Currently supported: ; wso_noaa New Fits files from NOAA ; wso_arge Old .dat files from NOAA ; nso_noaa Old Fits files from NOAA ; nso_ktpk New Fits files from Kit Peak ; OPTIONAL INPUTS: ; destination=destination ; scalar; type: string; default: $TUB ; directory where to write resulting source ; surface magnetic field (the file name is the ; same as for the file with the input photospheric ; magnetic field. ; list=list scalar; type: string; default: none ; name of file containing fully-qualified file names ; for all photospheric synoptic maps to be processed. ; source=source ; scalar; type: string; default: none ; used only if keyword list is not specified. ; Name of single photospheric magnetic map to be ; processed. ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, txt_read, SetFileSpec, GetFileSpec, brss_csss_scbf_ ; boost, wso_write, destroyvar, IsType, hide_env ; RESTRICTIONS: ; The input should not contain any holes. This sometimes happens with ; the WSO data received from NOAA when there are data gaps. ; Xuepu's code seems to return an array of zeros when this happens. ; MODIFICATION HISTORY: ; Jun 2002 (tjd, tdunn@ucsd.edu) ; Spt 2002 (tjd, tdunn@ucsd.edu) removed the intermediary ; printing of files to /xwso/sync, which formerly ; worked as a checking procedure, and is now commented out. ; Made code flexible to changes in $dat dir. ; NOV-2002, Paul Hick (UCSD/CASS) ; Modified XuePus readwsosc so that it can directly read ; Nicks files (it now calls wso_read). ; Writing of source surface magnetic field is now done using wso_write. ; OCT-2003, Paul Hick (UCSD/CASS) ; Modified to intercept photospheric maps with data gaps. These are ; now skipped. The modification required adding the keyword 'badfile' ; to some of Xuepus original code (gh_wbrsc, readwsosc). ; OCT-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added keyword remote_prefix to allow for a change in prefix from ; input file to output file (used for NSO/SOLIS maps). ;- InitVar, obs , 'wso_noaa' ; Observatory InitVar, remote_prefix, obs InitVar, local_prefix , obs InitVar, destination, getenv('TUB') InitVar, gzip, /key InitVar, rss, 15.0 ; Source surface distance (solar radii) InitVar, rcp, 1.6 ; ?? Cusp distance (solar radii) ghf = filepath(root=getenv('TUB'),'ghf.txt') ; Spherical harmonic expansion coeff ; Read master file CASE IsType(list, /defined) OF 0: BEGIN ; No list file, use keyword source nfile = n_elements(source) IF nfile GT 0 THEN infile = source END 1: BEGIN IF NOT txt_read(list, infile, nrec=nfile, /silent) THEN BEGIN message, /info, 'error reading master file '+hide_env(list) RETURN ENDIF message, /info, 'master file: '+hide_env(list)+' ('+strcompress(nfile,/rem)+' files)' END ENDCASE IF IsType(infile, /undefined) THEN BEGIN message, /info, 'no photospheric maps specified' RETURN ENDIF ;SetFileSpec, GetFileSpec(infile, part='name') ; Gets rid of double extensions like .dat.gz name = GetFileSpec(GetFileSpec(infile, part='name'),part='name') IF local_prefix NE remote_prefix THEN name = local_prefix+strmid(name,strlen(remote_prefix)) outfile = filepath(root=destination, name)+'.dat' IF (where(infile EQ outfile))[0] NE -1 THEN BEGIN message, /info, 'some in- and output file names are identical' RETURN ENDIF FOR i=0,nfile-1 DO BEGIN message, /info, hide_env(infile[i])+' --> '+hide_env(outfile[i]) destroyvar, header ; Safety belt, probably not necessary ; Xuepus original readwsosc procedure reads only the first 72 longitudes from ; the input file. The last record (same longitude as first, one rotation later) ; is discarded. ; This was changed so that now the first (oldest) longitude is discarded, ; and the last (most recent) longitude is retained. ; ; cvar contains Carrington variables for all 72 longitudes. brss_csss_scbf_, infile[i], obs, ghf, rcp=rcp, rss=rss, brad=brad, cvar=cvar, header=header, badfile=badfile CASE badfile OF 0: BEGIN ; Assume that brad is a 72x30 array with longitude (1st dim) and ; sine(latitude) (2nd dim) increasing with array index in equal steps. boost, header, [ $ 'RSS=' +strcompress(rss,/rem)+' solar radii', $ 'RCUSP='+strcompress(rcp,/rem)+' solar radii', $ 'BMAP='+hide_env(infile[i]), $ 'DESCRIPT=Radial magnetic field at source surface from brss_csss_scbf', $ '' ] ;wso_write, outfile[i], brad, cvar=cvar, header=header, /fill, badfillvalue=0.0, /addfirst IF gzip THEN status = gzip_file(outfile[i]) destroyvar, obstime fits_file = filepath(root=destination, GetFileSpec(outfile[i],part='name')+'.fts') wso_write, fits_file , brad, cvar=cvar, header=header, /fill, badfillvalue=0.0, /addfirst, obstime=obstime IF IsType(obstime,/defined) THEN BEGIN openw, /get_lun, iu, filepath(root=getenv('DAT'),subdir='map','last_'+obs+'_obs.txt') printf, iu, obstime, ' ', GetFileSpec(fits_file,from='name') free_lun, iu ENDIF END 1: message, /info, 'file skipped; probably bad data: '+infile[i] ENDCASE ENDFOR RETURN & END