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

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

Fixed tests and some bugs in na_content_collector.py

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