Commit db978845 authored by Ian Boyd's avatar Ian Boyd
Browse files

Replace geoms_online_conversion.pro

parent bfa7dd49
......@@ -9,74 +9,75 @@
; 2018-11-16, v0.1 Ian Boyd initial implementation
; 2020-10-20, v1.1 Ian Boyd compile with idlcr8hdf.pro v4.0b56
; 2020-10-26, v1.2 Ian Boyd compile with idlcr8hdf.pro v4.0b57
; 2020-12-11, v1.3 Ian Boyd compile with idlcr8hdf.pro v4.0b58
;---------------------------------------------------------------------------------------------------
PRO geoms_online_conversion
args = command_line_args()
iNrArgs = size(args, /N_ELEMENTS)
if ( iNrArgs ne 4 ) then begin
print
print, 'GEOMS online conversion'
print, ' Release v1.2, 2020-10-26'
print, ' Does conversion of input data and metadata files to GEOMS compliant HDF4/5 and netCDF files.'
print
print, 'usage: idl -rt=geoms_online_conversion.sav -args METAFILE ORIGDATAFILE(s) TAVFILE GEOMSFORMAT'
print
print, '1: METAFILE is the path and file name of the Metadata template file'
print, '2: ORIGDATAFILE(s) is the path and file name of the ASCII data file, or a path and filespec'
print, ' of a set of ASCII data files e.g. /data_dir/input.data or /data_dir/input*.data'
print, '3: TAVFILE is the path of the TAV file, you want to validate against'
print, '4. GEOMSFORMAT is the output format of the GEOMS file (H4, H5, NC)
print, '------------------------------------------------------------------------------------------------'
print
QA_error_code = 3
exit, status=QA_error_code
end
chFileMeta = STRTRIM( args( 0 ), 2 )
chFileData = STRTRIM( args( 1 ), 2 )
chFileTAV = STRTRIM( args( 2 ), 2 )
chFileFormat = STRTRIM( STRUPCASE( args( 3 ) ), 2 )
QA_error_code = 3
if ( file_test( chFileTAV ) eq 0 ) then begin
QA_error_code = 3
print, 'ERROR: TAV file not found.'
endif else QA_error_code = 0
if ( file_test( chFileMeta ) eq 0 ) then begin
QA_error_code = 3
print, 'ERROR: Metadata Template file not found.'
endif else QA_error_code = 0
arFileData=File_Search(chFileData, /Fully_Qualify_Path, count = fcnt )
if fcnt eq 0 then begin
QA_error_code = 3
print, 'ERROR: Data file(s) not found.'
endif else QA_error_code = 0
AllowedFormats=['H4','H5','NC']
gi = WHERE(chFileFormat eq AllowedFormats, gcnt)
if gcnt eq 0 then begin
QA_error_code = 3
print, 'ERROR: Output format must be H4, H5 or NC.'
endif else QA_error_code = 0
if ( QA_error_code eq 0 ) then begin
case 1 of
chFileFormat eq 'H4': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /AVK, /Log
chFileFormat eq 'H5': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /H5, /AVK, /Log
chFileFormat eq 'NC': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /NC, /AVK, /Log
endcase
end
exit, status=QA_error_code
args = command_line_args()
iNrArgs = size(args, /N_ELEMENTS)
if ( iNrArgs ne 4 ) then begin
print
print, 'GEOMS online conversion'
print, ' Release v1.3, 2020-12-11'
print, ' Does conversion of input data and metadata files to GEOMS compliant HDF4/5 and netCDF files.'
print
print, 'usage: idl -rt=geoms_online_conversion.sav -args METAFILE ORIGDATAFILE(s) TAVFILE GEOMSFORMAT'
print
print, '1: METAFILE is the path and file name of the Metadata template file'
print, '2: ORIGDATAFILE(s) is the path and file name of the ASCII data file, or a path and filespec'
print, ' of a set of ASCII data files e.g. /data_dir/input.data or /data_dir/input*.data'
print, '3: TAVFILE is the path of the TAV file, you want to validate against'
print, '4. GEOMSFORMAT is the output format of the GEOMS file (H4, H5, NC)
print, '------------------------------------------------------------------------------------------------'
print
QA_error_code = 3
exit, status=QA_error_code
end
chFileMeta = STRTRIM( args( 0 ), 2 )
chFileData = STRTRIM( args( 1 ), 2 )
chFileTAV = STRTRIM( args( 2 ), 2 )
chFileFormat = STRTRIM( STRUPCASE( args( 3 ) ), 2 )
QA_error_code = 3
if ( file_test( chFileTAV ) eq 0 ) then begin
QA_error_code = 3
print, 'ERROR: TAV file not found.'
endif else QA_error_code = 0
if ( file_test( chFileMeta ) eq 0 ) then begin
QA_error_code = 3
print, 'ERROR: Metadata Template file not found.'
endif else QA_error_code = 0
arFileData=File_Search(chFileData, /Fully_Qualify_Path, count = fcnt )
if fcnt eq 0 then begin
QA_error_code = 3
print, 'ERROR: Data file(s) not found.'
endif else QA_error_code = 0
AllowedFormats=['H4','H5','NC']
gi = WHERE(chFileFormat eq AllowedFormats, gcnt)
if gcnt eq 0 then begin
QA_error_code = 3
print, 'ERROR: Output format must be H4, H5 or NC.'
endif else QA_error_code = 0
if ( QA_error_code eq 0 ) then begin
case 1 of
chFileFormat eq 'H4': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /AVK, /Log
chFileFormat eq 'H5': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /H5, /AVK, /Log
chFileFormat eq 'NC': idlcr8hdf, chFileMeta, arFileData, chFileTav, 'M', /NC, /AVK, /Log
endcase
end
exit, status=QA_error_code
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment