source: nappy/trunk/nappy/nc_interface/test_1010_to_1020.py @ 3470

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/nc_interface/test_1010_to_1020.py@3470
Revision 3470, 904 bytes checked in by astephen, 12 years ago (diff)

Got 1020 written from NetCDF.

Line 
1import cdms
2
3print "Writing a 1020 file from 1010 already converted to NetCDF..."
4ncfile = "../../test_outputs/1010.nc"
5f=cdms.open(ncfile)
6p_new = f('pressure', altitude=(10,85))
7o_new = f('ozone_concentration', altitude=slice(0,16,4))
8out_file = cdms.open("../../test_outputs/1010_edited_for_1020.nc", "w")
9out_file.write(p_new)
10out_file.write(o_new)
11for att, value in f.attributes.items():
12    setattr(out_file, att, value)
13out_file.close()
14print "Outfile written:", ncfile
15
16import na_to_nc
17import nc_to_na
18import os
19
20in_dir = "../../data_files"
21out_dir = "../../test_outputs"
22in_dir = out_dir
23
24
25ffi_in, ffi_out = (1010, 1020)
26
27infile = os.path.join(in_dir, "%s_edited_for_%s.nc" % (ffi_in, ffi_out))
28outfile = os.path.join(out_dir, "%s_from_nc_%s.na" % (ffi_out, ffi_in))
29
30print "Reading:", infile
31x = nc_to_na.NCToNA(infile, requested_ffi=ffi_out)
32
33print "Writing:", outfile
34x.writeNAFiles(outfile)
Note: See TracBrowser for help on using the repository browser.