originnbintobas.title="Number of sub-grid basin into current one before truncation"
originnbintobas.units="-"
else:
originnbintobas=np.zeros((1,1))
originnbintobas[:,:]=part.gather(onbintobas)
################
#
# The field route_togrid is with indices on the local grid. That needs to be converted to the global grid.
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"routetogrid","Grid into which the basin flows","-",grgrid,vtyp,"int")
# route to basin
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"routetobasin","Basin in to which the water goes","-",self.route_tobasin[:,:],vtyp,"int")
# basin id
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"basinid","ID of basin","-",self.global_basinid[:,:],vtyp,"int")
#
# basin area
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"basin_area","area of basin","m^2",self.routing_area[:,:],vtyp,"float")
# route number into basin
self.add_variable(outnf,procgrid,NCFillValue,part,('y','x'),"routenbintobas","Number of basin into current one","-",self.route_nbintobas[:],vtyp,"int")
#
# original number into basin
self.add_variable(outnf,procgrid,NCFillValue,part,('y','x'),"originnbintobas","Number of sub-grid basin into current one before truncation","-",self.origin_nbintobas[:],vtyp,"int")
#
# latitude of outlet
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"outletlat","Latitude of Outlet","degrees north",self.route_outlet[:,:,0],vtyp,"float")
# longitude of outlet
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"outletlon","Longitude of Outlet","degrees east",self.route_outlet[:,:,1],vtyp,"float")
# type of outlet
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"outlettype","Type of outlet","code",self.route_type[:,:],vtyp,"float")
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"topoindex","Topographic index of the retention time","m",self.topo_resid[:,:],vtyp,"float")
self.add_variable(outnf,procgrid,NCFillValue,part,('inflow','htu','y','x'),"route_ingrid","Grid from which the water flows","-",self.route_ingrid[:,:,:],vtyp,"int")
topoindex.title="Topographic index of the retention time"
topoindex.units="m"
else:
topoindex=np.zeros((1,1,1))
topoindex[:,:,:]=part.gather(tind)
# Inflow basin
self.add_variable(outnf,procgrid,NCFillValue,part,('inflow','htu','y','x'),"route_inbasin","Basin from which the water flows","-",self.route_inbasin[:,:,:],vtyp,"int")
CG_lat.title="Latitude of centre of gravity of HTU"
CG_lat.units="degrees north"
else:
CG_lon=np.zeros((1,1,1))
CG_lat=np.zeros((1,1,1))
CG_lon[:,:,:]=part.gather(cg[1,:,:,:])
CG_lat[:,:,:]=part.gather(cg[0,:,:,:])
# Check if it works
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"CG_lon","Longitude of centre of gravity of HTU","degrees east",self.routing_cg[:,:,1],vtyp,"float")
self.add_variable(outnf,procgrid,NCFillValue,part,('htu','y','x'),"CG_lat","Latitude of centre of gravity of HTU","degrees north",self.routing_cg[:,:,0],vtyp,"float")