Module helper_module
[hide private]
[frames] | no frames]

Source Code for Module helper_module

 1  """ 
 2  This is a place for small helper functions to live. 
 3  """ 
 4   
 5  import os 
 6  import Scientific.IO.NetCDF 
 7   
8 -def CDL2nc(input_file, output_file=None):
9 """ 10 Makes a netCDF file from a text file in the CDL format. 11 12 @type input_file: string 13 @param input_file: The name of the input file. 14 15 @type output_file: string 16 17 @param output_file: The name of the output file, if none is given 18 the same name as the CDL file is used with a 19 C{.nc} extension. 20 """ 21 if output_file is None: 22 output_file = os.path.splitext(input_file)[0] + '.nc' 23 # run the command ncgen 24 os.system('ncgen -o ' + output_file + ' ' + input_file)
25
26 -def nc2CDL(input_file, output_file=None):
27 """ 28 Performs a C{ncdump}. 29 30 @type input_file: string 31 @param input_file: The name of the input file. 32 33 @type output_file: string 34 35 @param output_file: The name of the output file, if none is given 36 the same name as the netCDF file is used with a 37 C{.CDL} extension. 38 """ 39 if output_file is None: 40 output_file = os.path.splitext(input_file)[0] + '.CDL' 41 # run ncdump 42 os.system('ncdump ' + input_file + ' > ' + output_file)
43 44
45 -def open_netCDF_into_python(input_file, rw_opt='r'):
46 """ 47 This opens a netCDF file. 48 49 @type input_file: string 50 @param input_file: The netCDF file to be read. 51 52 @type rw_opt: stirng 53 @param rw_opt: Reading 'r' (default), writing 'w' 54 55 @return: A C{Scientific.IO.NetCDF.NetCDFFile} instance 56 """ 57 if type(input_file)!=type(''): 58 input_file = str(input_file) 59 return Scientific.IO.NetCDF.NetCDFFile(input_file, rw_opt)
60 61 if __name__=='__main__': 62 pass 63