Commit dad41b15 authored by Anthony's avatar Anthony
Browse files

Add lon/ lat variables to the Diagnostic file.

parent bbf74fde
......@@ -294,12 +294,13 @@ class PlacedLocations :
self.lonrange = [np.min(nc.variables["lon"][:,:]), np.max(nc.variables["lon"][:,:])]
self.latrange = [np.min(nc.variables["lat"][:,:]), np.max(nc.variables["lat"][:,:])]
# Parameters
#to improve
basid = nc.variables["basinid"][:,:,:]
self.nbasmax = basid.shape[0]
land = nc.variables["land"][:,:]
self.nbpt = int(np.sum(land))
self.lnglat = {varn: nc.variables[varn][:] for varn in ["lon", "lat"]}
# Grid points
self.nbpt_glo = nc.variables["nbpt_glo"][:]
a = np.unravel_index(ma.argsort(self.nbpt_glo, axis = None)[:self.nbpt], self.nbpt_glo.shape)
......@@ -88,6 +88,16 @@ nc.createDimension('x', L.gridshape[1])
nc.createDimension('y', L.gridshape[0])
nc.setncattr("RoutingGraph_File", GraphFile)
nc.setncattr("GRDCObservation_File", GRDCFile)
# Lon and Lat variables
D = {"lon": ["degrees east", "Longitude", "X"],
"lat": ["degrees north","Latitude", "Y"]}
NCFillValue = 1.0e20
for vname in ["lon", "lat"]:
var = nc.createVariable(vname, float, ('y','x'), fill_value=NCFillValue)
var[:] = L.lnglat[vname][:]
var.units="grid box centre "+D[vname][0]
# Create variables only if the GRDC station has been placed on the graph
for i,loc in enumerate(Lind) :
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment