from __future__ import print_function import numpy as np from netCDF4 import Dataset import os import sys ########################################### print("Python Script:\t" + repr(sys.argv[0])) ## ## input file specified on the command line ## load the data into the numpy array ## if len(sys.argv) == 3: # Read the input file as the first argument input_file = os.path.expandvars(sys.argv[1]) data_name = sys.argv[2] try: # Print some output to verify that this script ran print("Input File:\t" + repr(input_file)) print("Data Name:\t" + repr(data_name)) input_nc = Dataset(input_file,'a',format='NETCDF4') #print(input_nc.variables.keys()) data = input_nc.variables[data_name][:] met_data = data[::-1].copy() print("Data Shape:\t" + repr(met_data.shape)) print("Data Type:\t" + repr(met_data.dtype)) except NameError: print("Can't find the input file") else: print("ERROR: read_ascii_numpy.py -> Must specify exactly one input file and a name for the data.") sys.exit(1) ########################################### ## ## create the metadata dictionary ## attrs = { 'valid': '20230501_010000', 'init': '20230501_000000', 'lead': '010000', 'accum': '010000', 'name': data_name, 'long_name': 'Composite Relectivity', 'level': 'Surface', 'units': 'dBZ', 'grid': { 'type': 'Lambert Conformal', 'hemisphere': 'N', 'name': 'FooGrid', 'scale_lat_1': 38.5, 'scale_lat_2': 38.5, 'lat_pin': 21.138123, 'lon_pin': -122.719528, 'x_pin': 0.0, 'y_pin': 0.0, 'lon_orient': -97.5, 'd_km': 3.0, 'r_km': 6371.2, 'nx': 1155, 'ny': 959, } } print("Attributes:\t" + repr(attrs))