ccht-ncsu / Kalpana

Visualization of ADCIRC Model Data in Vector Formats
GNU General Public License v3.0
26 stars 22 forks source link

TypeError: 'map' object is not subscriptable [maxelev.nc + kmz option] #42

Closed msw09090 closed 1 year ago

msw09090 commented 1 year ago

Hello,

I've encountered an issue while trying to generate a kmz file (maxelev.nc).

My command was: python kalpana.py --storm ian --filetype maxele.63.nc --polytype polygon --contourrange "0 15 0.5" --units english --palettename alt-water-level.pal

I received the following error: Traceback (most recent call last): File "~/kalpana.py", line 712, in bins.append([local[1],gdomain[1],gdomain[2],gdomain[3]]) TypeError: 'map' object is not subscriptable

The (error) section of script is:

DEFINING BINS FOR KML CREATION

if viztype == 'kmz': gdomain = [50,5,-60,-100] local = map(float,l.split()) bins = [] bins.append([local[1],gdomain[1],gdomain[2],gdomain[3]]) north = local[1] + 0.5 south = local[1] while (north <= local[0]): bins.append([north,south,gdomain[2],gdomain[3]]) south = north north = north +0.5 bins.append([gdomain[0],local[0],gdomain[2],gdomain[3]])

print bins

Any idea of the problem?

tomas19 commented 1 year ago

Hi, we changed the structure of the repository. Inside Kalpana/kalpana we have 2 python packages (python scripts with only functions), and in Kalpana/scripts there are some examples of how to call the functions. If you want to export a maxelev.63.nc file to kmz, you just need to call the 'nc2kmz' function, which inside the export package.

Tomás

msw09090 commented 1 year ago

Thanks for the response!

Was this change done recently? I installed Kalpana last month and I noticed the 'module' directory (I saw it recently, but I can't see it on your github page now) wasn't included with the clone/install. Based on "runKalpanaExport_sa.py," the "scriptPath" field must be set to the 'module' path, correct (where 'kalpanaExport.py' is located)? I do not have kalpanaExport.py anywhere in my cloned, github repository.

scriptPath = r'/source_code/utilities/Kalpana'

I installed everything as follows:

1) Save the following .yml file: " name: env_kalpanaH2 channels:

msw09090 commented 1 year ago

To answer my question, if you installed Kalpana recently and assuming that export.py==kalpanaExport.py (which I believe it is), copy 'export.py' as 'kalpanaExport.py...' export.py is in the ~/utilities/Kalpana/ directory. The symbol '~' represents your install/build directory.

Next, I had to change the call function (nc2kmz as provided by the 'runKalpanaExport_sa.py' example script) from, gdf = nc2kmz(ncFile, var, levels, conType, epsg, pathOut, vUnitOut, vDatumIn, vDatumOut) to, gdf = nc2kmz(ncFile, var, levels, conType, epsg, pathOut, vUnitIn, vUnitOut, vDatumIn, vDatumOut, subDomain=None, overlay=True, logoFile='logo.png', colorbarFile='tempColorbar.jpg', cmap='viridis', thresVertices=20_000) Just follow how the function is called in kalpanaExport.py and you should be fine.

Next, just run kalpanaExport.py: python kalpanaExport.py - make sure your environment is active.