- Timestamp:
- Dec 13, 2018 12:18:54 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_csd_files/palm_csd_netcdf_interface.py
r3567 r3629 25 25 # ----------------- 26 26 # $Id$ 27 # Some new routines 28 # 29 # 3567 2018-11-27 13:59:21Z maronga 27 30 # Initial revisions 28 #29 #30 #31 #32 31 # 33 32 # Description: … … 76 75 nc_file = Dataset(filename, "r+", format="NETCDF4") 77 76 tmp_array = np.array(nc_file.variables[varname][:][:], dtype=type(nc_file.variables[varname])) 77 78 return tmp_array 79 80 def nc_read_from_file_3d_all(filename, varname): 81 82 83 import numpy as np 84 import sys 85 86 try: 87 f = open(filename) 88 f.close() 89 # print("Load: " + filename + ".") 90 except FileNotFoundError: 91 print("Error: " + filename + ". No such file. Aborting...") 92 sys.exit(1) 93 94 nc_file = Dataset(filename, "r+", format="NETCDF4") 95 tmp_array = np.array(nc_file.variables[varname][:][:][:], dtype=type(nc_file.variables[varname])) 78 96 79 97 return tmp_array … … 212 230 return 0 213 231 232 def nc_overwrite_to_file_3d(filename,varname,array): 233 234 try: 235 f = Dataset(filename, "a", format="NETCDF4") 236 #print("Opened: " + filename + ".") 237 except FileNotFoundError: 238 print("Error. Could not open file: " + filename + ". Aborting...") 239 sys.exit(1) 240 241 print("Writing array " + varname + " to file...") 242 243 temp = f.variables[varname] 244 temp[:,:,:] = array 245 246 f.close() 247 248 return 0 249 214 250 def nc_write_to_file_3d(filename,varname,array,datatype,dimname1,dimname2,dimname3,fillvalue): 215 251
Note: See TracChangeset
for help on using the changeset viewer.