Closed glw closed 1 month ago
Hi Garret
The second argument of the nc2shp function allows you to specify the variable you want to export.
No, Kalpana can't export multiple variables at once. What you can do is to run it as many times as variables you want to export. It shouldn't take too long. The nc2shp function uses dask so it computes the contours in parallel.
Please let me know if you have further questions Tomas
Hi so it looks like there is some type of issue for me when using the polygon
setting for conType
, when using ncshp()
. But polyline
seems to work just fine.
A little background on what Im doing... I am adding additional data variables (covering different scenarios) to the NC file after the fact and these additional variables seem to be the issue. Even though Ive tried to copy the same metadata and data type from the original zeta_max
variable.
NetCDFs are a bit new to me so I may be missing something. The error below does mention levels
so Ive tried a few different examples of those, but nothing seems to satisfy the requirements.
Here's the error:
ValueError Traceback (most recent call last)
Cell In[16], line 2
1 ## call nc2shp() and store output as geodataframe
----> 2 gdf = nc2shp(ncFile, var, levels, conType, pathOut, epsgOut, vUnitOut=vUnitOut, vUnitIn=vUnitIn, epsgIn=epsgIn,
3 subDomain=subDomain, exportMesh=exportMesh, meshName=meshName, dzFile=dzFile, zeroDif=zeroDif)
File ~/Kalpana/kalpana/export.py:818, in nc2shp(ncFile, var, levels, conType, pathOut, epsgOut, vUnitOut, vUnitIn, epsgIn, subDomain, epsgSubDom, exportMesh, meshName, dzFile, zeroDif, timesteps)
816 stepLevel = levels[2]
817 ## list of levels to array
--> 818 levels_aux = np.arange(levels[0], np.ceil(maxmax) + 2*stepLevel, stepLevel)
819 ## given levels will now match the avarege value of each interval
820 levels_aux = levels_aux - stepLevel/2
ValueError: arange: cannot compute length
To summarize, the same script works if you set the conType
parameter to polyline
but fails when conType
is polygon
.
Please double-check that you are providing the inputs to nc2shp
in the correct order. And, can you try to do np.max(nc[var][:].data)
. nc
is the NetCDF file, and var
is your new variable. When conType
is set to polygon
Kalpana modifies the levels specified to avoid excluding values.
Let me know how it goes Tomas
Yes that is correct as you've described. Im currently using the notebooks from the repo and have been using those to work with. But I will double check everything so that Im sure of the correct order. Thank you!
hi @tomas19 Ive double checked my inputs for nc2shp. They are as they appear in the export_example2.ipynb
gdf = nc2shp(ncFile, var, levels, conType, pathOut, epsgOut, vUnitOut=vUnitOut, vUnitIn=vUnitIn, epsgIn=epsgIn,
subDomain=subDomain, exportMesh=exportMesh, meshName=meshName, dzFile=dzFile, zeroDif=zeroDif)
Also for np.max(ds['low_2yr'][:].data)
, I get nan
But if I use np.nanmax(ds['low_2yr'][:].data)
, then max is 162.8...
zeta_max
here... I was finally able to get Kalpana to work with any variable that was formatted similarly to zeta_max
. Hi Garret,
The problem is that the function doesn't expect the NetCDF to have nans
. Dry vertices on ADCIRC outputs have -99999
in my experience. I'll change the function to deal with nans
but I'm a bit busy , I'll need do some tests before.
In the meanwhile, modify the variable of your NetCDF file with np.nan_to_num
to set the nans
to -99999
.
For running the downscaling functions you will need to export the ADCIRC outputs as contours, but that is the default on the runStatic
function.
Great! Thanks for your help on trouble shooting this @tomas19. I will update the nans
.
Just re-ran the file without the nans, everything went through as expected. Thanks again!
I re-open the issue to have it as a reminder I need to implement this
Hi Ive worked through your example notebook export_example02.ipynb and was successful in outputting a contour of my zetamax. I noticed though that Kalpana is not able to take variables other than zetamax to create a contour?
In a scenario where you have multiple variables you'd like to run within a single netcdf file, are there options available within Kalpana where it could create separate contours for each variable?