Ignore:
Timestamp:
Dec 13, 2018 12:18:54 PM (6 years ago)
Author:
maronga
Message:

palm_csd improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palm_csd_files/palm_csd_netcdf_interface.py

    r3567 r3629  
    2525# -----------------
    2626# $Id$
     27# Some new routines
     28#
     29# 3567 2018-11-27 13:59:21Z maronga
    2730# Initial revisions
    28 #
    29 #
    30 #
    31 #
    3231#
    3332# Description:
     
    7675   nc_file = Dataset(filename, "r+", format="NETCDF4")
    7776   tmp_array = np.array(nc_file.variables[varname][:][:], dtype=type(nc_file.variables[varname]))
     77
     78   return tmp_array
     79
     80def 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]))
    7896
    7997   return tmp_array
     
    212230   return 0
    213231
     232def 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
    214250def nc_write_to_file_3d(filename,varname,array,datatype,dimname1,dimname2,dimname3,fillvalue):
    215251
Note: See TracChangeset for help on using the changeset viewer.