-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key Error When Running Code with FES2022 #569
Comments
Wanted to add some additional information, I modified it to be: And no longer had issues with the ocean_short variable in the S_slope.compute_tide module being nan While this allows me to pull a tidal time-series from FES2022 now, I still am getting a key error on that section. |
You may want to try moving the point a couple kms offshore, due to the nature of the model, if it doesn't have data for the requested coordinates, it interpolates selecting points near the coordinates you provided. If any of these coordinates are on land, it wont give you a usable tide level. |
Thanks! I did try this, but it was the error I mentioned above that was creating issues. Still having trouble with the key error though. |
What are the keys in both of the dictionaries if you print both of them? Could help to diagnose the issue, like before entering the loop where the error occurs add a
The exception shows that it can't find a matching key in df that exists in transects, I don't know too much about np.array but this could be making them all into int instead of string or something similar that could be the cause. |
I was just exploring this as well, Phillip. I have not changed anything in the code that I think would modify the key values to not work... Im wondering what is going on. |
Do the Keys need to be listed as "Transect 1", "Transect 2" etc...? |
Oh! I remember running into this a while back, its due to the naming of the transects. You'll see in df they're all |
@phillipjws Let me try this out and run through the code again completely. I did try some piecewise adjustments and got it passed that df[key] issue but it choked on another couple problem: |
yes well spotted @phillipjws , it's an issue with the keys of the dictionnary (name of the transects). Make sure the name of the transects matches with cross_distance, otherwise it will break |
@kvos any thoughts on these boolean errors that occur after I address the key error? |
Hello Again (sorry to be asking so many questions) ,
I installed FES2022 and I think I have corrected the python script in all the places required to point towards the NetCDF files, however when I try and run the model with tide prediction and beach slope, I am getting the following error:
`Traceback (most recent call last):
File ~\AppData\Local\miniforge3\envs\coastsat\Lib\site-packages\pandas\core\indexes\base.py:3805 in get_loc
return self._engine.get_loc(casted_key)
File index.pyx:167 in pandas._libs.index.IndexEngine.get_loc
File index.pyx:196 in pandas._libs.index.IndexEngine.get_loc
File pandas\_libs\hashtable_class_helper.pxi:7081 in pandas._libs.hashtable.PyObjectHashTable.get_item
File pandas\_libs\hashtable_class_helper.pxi:7089 in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: '1'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ~\AppData\Local\miniforge3\envs\coastsat\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)
File c:\coastsat-master\cape_disappointment_coastsat_small.py:370
cross_distance[key] = np.array(df[key])
File ~\AppData\Local\miniforge3\envs\coastsat\Lib\site-packages\pandas\core\frame.py:4102 in getitem
indexer = self.columns.get_loc(key)
File ~\AppData\Local\miniforge3\envs\coastsat\Lib\site-packages\pandas\core\indexes\base.py:3812 in get_loc
raise KeyError(key) from err
KeyError: '1'`
This is followed by the code producing some plots, but the tidal plot has no output and is completely blank.
thanks for any guidance, I couldnt find any similar issues to help me resolve this.
I've attached a copy of the code I've modified below if it helps at all.
CoastSat_Cape_D.txt
The text was updated successfully, but these errors were encountered: