Open zackarno opened 1 year ago
A shoot, good find Zach. Interesting that it works with other coordinates. Can you share the URL that it generates for LAC? Or at least the geo bounding box coordinates. I tried to reproduce a successful download but I'm unable to.
My initial thought was that it's something with the authentication (like maybe our key is expired), because I get the same error when I use a bogus key. But if it works for other locations then maybe that points to something on their end?
so you do get the same error when running the example from the documentation but w/ "som" ? I also tried w/ "bdi" and had the same issue.
Not sure about the state of the authentication key, but I agree it would be odd that it seems to work w/ the modified workflow (supplying a bbox of Central America and a dummy yaml).
So here is what the bounding box created printed in R looks like:
xmin ymin xmax ymax
-92.22925 10.72684 -83.14722 17.81933
and here it is as an array for python:
array([[-92.22924862, 10.7268391 ],
[-83.147219 , 10.7268391 ],
[-83.147219 , 17.81932608],
[-92.22924862, 17.81932608],
[-92.22924862, 10.7268391 ]])
I'd think you can just plug it into the workflow above like this?
import numpy as np
aoi_poly = Polygon(np.array([[-92.22924862, 10.7268391 ],
[-83.147219 , 10.7268391 ],
[-83.147219 , 17.81932608],
[-92.22924862, 17.81932608],
[-92.22924862, 10.7268391 ]]))
gdf_aoi_poly = gpd.GeoDataFrame({'geometry':[aoi_poly]})
this does work for me. I think unless you remove the LAC IRI forecast .nc
file from the AA_DATA_DIR
it won't actually download again? but if i remove it... it does work and re-downloads.
@zackarno does this work for you? It does NOT for me:
import os
from ochanticipy import (
create_country_config,
GeoBoundingBox,
IriForecastProb,
)
os.environ["OAP_DATA_DIR"] = "/tmp"
# The country used shouldn't matter because nothing in the
# config file is used for IRI
country_config = create_country_config(iso3="som")
geo_bounding_box = GeoBoundingBox(
lat_max=17.8, lat_min=10.7, lon_max=--83.1, lon_min=-92.2
)
iri_prob = IriForecastProb(
country_config=country_config, geo_bounding_box=geo_bounding_box
)
iri_prob.download()
that worked for me!
Can you try with clobber=True
in download()
, but even better try this:
import os
from pathlib import Path
import requests
from ochanticipy import (
create_country_config,
GeoBoundingBox,
IriForecastProb,
)
os.environ["OAP_DATA_DIR"] = str(Path("/tmp"))
country_config = create_country_config(iso3="som")
geo_bounding_box = GeoBoundingBox(
lat_max=17.8, lat_min=10.7, lon_max=--83.1, lon_min=-92.2
)
iri_prob = IriForecastProb(
country_config=country_config, geo_bounding_box=geo_bounding_box
)
url = iri_prob._get_url()
response = requests.get(
url,
# have to authenticate by using a cookie
cookies={"__dlauth_id": os.getenv("IRI_AUTH")},
)
At the end it's a Python version issue. Works for versions <3.10:
https://stackoverflow.com/a/73230534
Wil try to fix it when I can, but in the meantime a (less than ideal) workaround is to use Python 3.9 for downloading IRI.
Note that I was able to successfully run this on 3.11.2 recently, just when I was blindly running some code for a review: exploration/iri.md.
Note that I was able to successfully run this on 3.11.2 recently, just when I was blindly running some code for a review: exploration/iri.md.
Did it actually download though? Because all the data would've already been there from when I ran it. When actually downloading with clobber=True
, it didn't work for me with 3.11.4 so I just made a separate 3.9 environment just for downloading.
Ah yeah, that's probably what happened, forgot clobber = False
.
Note that this also happens with CHIRPS, which makes sense because that is also coming from IRI
Im probably doing something wrong here, but not sure why I can't get the example from the documentation to work when I change the country_config iso3 to "som"
Heres the code:
error comes from here:
I get the same error when trying any other country config (HRP) where we dont already have the data downloaded. Oddly, I was able to download for Nicaragua, El Salvador, Honduras, Guatemala all together with the below mixed python-R work flow (but this was not reproducible for SOM)