source: nappy/trunk/nappy/unit_tests/test_1010_to_1020.py @ 3525

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/unit_tests/test_1010_to_1020.py@3525
Revision 3525, 1.0 KB checked in by astephen, 12 years ago (diff)

Fixed imports in test.

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