- Timestamp:
- Jan 14, 2019 12:49:24 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_csd_files/palm_csd_netcdf_interface.py
r3629 r3668 25 25 # ----------------- 26 26 # $Id$ 27 # Some improvements and new routines 28 # 29 # 3629 2018-12-13 12:18:54Z maronga 27 30 # Some new routines 28 31 # … … 39 42 40 43 from netCDF4 import Dataset 44 45 def nc_read_from_file_1d_all(filename, varname): 46 47 48 import numpy as np 49 import sys 50 51 try: 52 f = open(filename) 53 f.close() 54 # print("Load: " + filename + ".") 55 except FileNotFoundError: 56 print("Error: " + filename + ". No such file. Aborting...") 57 sys.exit(1) 58 59 nc_file = Dataset(filename, "r+", format="NETCDF4") 60 tmp_array = np.array(nc_file.variables[varname][:] , dtype=type(nc_file.variables[varname])) 61 62 return tmp_array 41 63 42 64 def nc_read_from_file_2d(filename, varname, x0, x1, y0, y1): … … 174 196 return 0 175 197 198 def nc_write_global_attribute(filename,attribute,value): 199 200 import datetime 201 import os 202 203 print("Writing attribute " + attribute + " to file...") 204 205 f = Dataset(filename, "a", format="NETCDF4") 206 207 f.setncattr(attribute,value) 208 209 f.close() 210 176 211 177 212 def nc_write_dimension(filename,varname,array,datatype):
Note: See TracChangeset
for help on using the changeset viewer.