Ignore:
Timestamp:
Jan 14, 2019 12:49:24 PM (5 years ago)
Author:
maronga
Message:

removed most_methods circular and lookup. added improved version of palm_csd

File:
1 edited

Legend:

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

    r3629 r3668  
    2525# -----------------
    2626# $Id$
     27# Some improvements and new routines
     28#
     29# 3629 2018-12-13 12:18:54Z maronga
    2730# Some new routines
    2831#
     
    3942
    4043from netCDF4 import Dataset
     44
     45def 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
    4163
    4264def nc_read_from_file_2d(filename, varname, x0, x1, y0, y1):
     
    174196   return 0
    175197
     198def 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
    176211
    177212def nc_write_dimension(filename,varname,array,datatype):
Note: See TracChangeset for help on using the changeset viewer.