;+ ; ; Laboratory for Atmospheric and Space Physics ; University of Colorado, Boulder, Colorado, USA ; ; FILENAME: ; cips_server__define.pro ; ; AUTHOR: ; Lon Riesberg ; ; DATE: ; August 30, 2005 ; ; PURPOSE: ; Base class for CIPS server objects. ; ; BACKGROUND: ; ; REFERENCES: ; ; NOTES: ; ; CONSTRAINTS: ; ; OTHER SERVERS/MODULES USED: ; ; RELATED MODULES / CLASSES: ; ; SUPPORTING DATABASE TABLES OR FILES: ; CIPS Data Product Version File ; ; ---------------------------------------------------------------------- ; CONSTRUCTOR ; ---------------------------------------------------------------------- ; INPUT PARAMETERS: ; client_server - calling server object ; ; OUTPUT PARAMETERS: ; NONE ; ; RETURN VALUE: ; A value of 1 is returned if the initialization was successful ; ; KEYWORD ARGUMENTS: ; NONE ; ;- function cips_server::INIT, client_server, product_type, _extra = extra self.client_server = ptr_new(client_server) self.version = lookup_version(product_type, revision=revision) self.revision = revision return, 1 end ;-------------------------------------------------------------------------- ; Procedure get_netcdf_att_filename ; -------------------------------------------------------------------------- ; PURPOSE: ; Returns the file name and path of the netCDF attribute file. ; ; INPUT PARAMETERS: ; data_level - the product data level to return the attribute file name for ; ; OUTPUT PARAMETERS: ; None ; ; KEYWORD ARGUMENTS: ; None ; function cips_server::get_netcdf_att_filename, data_level att_file= !cips_netcdf_att_path+strupcase(string(data_level,format='(%"/l%s_cips_struct.att")')) if ~file_test(att_file) then message, "no attribute file found for data level" + data_level, /info return, att_file end ;-------------------------------------------------------------------------- ; Procedure write_cips_file ; -------------------------------------------------------------------------- ; PURPOSE: ; Writes cips data to a file. ; ; INPUT PARAMETERS: ; data - the data to write ; fn - the name of the file to write to ; ; OUTPUT PARAMETERS: ; None ; ; KEYWORD ARGUMENTS: ; net_cdf - if set, indicates that the file should be saved as a netCDF file. ; data_level - the product data level to return the netCDF attribute file name for. ; pro cips_server::write_cips_file, data, filename, net_cdf=net_cdf, data_level=data_level print, 'saving file to ', filename if keyword_set(net_cdf) then begin att_file = self->get_netcdf_att_filename(data_level) IF FILE_TEST( filename ) THEN FILE_DELETE, filename write_netCDF, data, filename, status, att_file=att_file, /clobber ; if netCDF write error, display status else compress if status ne 0 then message, 'write_netCDF returned with status: ' + string(status, format='(i0)'), /info else begin gzip_cmd = 'gzip -c ' + filename +' > ' + filename + '.gz' spawn, gzip_cmd rm_cmd = 'rm ' + filename spawn, rm_cmd endelse endif else begin save, data, filename=filename endelse return end ;-------------------------------------------------------------------------- ; CLEANUP ; -------------------------------------------------------------------------- pro cips_server::CLEANUP ptr_free, self.client_server obj_destroy, self end ; -------------------------------------------------------------------------- ; Object Data Structure Definition ; -------------------------------------------------------------------------- pro cips_server__define self = {cips_server, $ version:' ', $ revision:' ', $ client_server:ptr_new()} return end