Skip to content
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

ValueError: conflicting sizes for dimension 'band': length 4 on <this-array> and length 19 on {'band': 'band', 'y': 'y', 'x': 'x'} #132

Open
ofcosar opened this issue Mar 29, 2024 · 2 comments

Comments

@ofcosar
Copy link

ofcosar commented Mar 29, 2024

Hello @gabrieltseng and CropHarvest team,
Actually ı am newbie about usage. what ı did is ı exported a tif file using export_for_labels method:
private_labels = pd.DataFrame({ "lon": [min_lon, max_lon], "lat": [min_lat, max_lat], "start_date": [date(2021, 1, 1), date(2021, 1, 1)], "end_date": [date(2022, 1, 1), date(2022, 1, 1)] }) private_labels google_cloud_exporter.export_for_labels(labels=private_labels)

Until this point, everything is good ı exported tif file succesfully and ı downloaded. After that
ı tried to test my exported tif file in the model here it is:

preds = Inference(model=modelp, normalizing_dict=None).run(local_path = f)
but ı get this error

preds = Inference(model=modelp, normalizing_dict=None).run(local_path = f) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cropharvest/inference.py", line 89, in run x_np, flat_lat, flat_lon = Engineer.process_test_file(local_path, start_date) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cropharvest/engineer.py", line 405, in process_test_file da, slope = Engineer.load_tif(path_to_file, start_date=start_date) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cropharvest/engineer.py", line 236, in load_tif time_specific_da["band"] = range(bands_per_timestep + len(STATIC_BANDS)) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xarray/core/dataarray.py", line 754, in __setitem__ self.coords[key] = value File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xarray/core/coordinates.py", line 41, in __setitem__ self.update({key: value}) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xarray/core/coordinates.py", line 166, in update self._update_coords(coords, indexes) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xarray/core/coordinates.py", line 342, in _update_coords dims = calculate_dimensions(coords_plus_data) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xarray/core/dataset.py", line 208, in calculate_dimensions raise ValueError( ValueError: conflicting sizes for dimension 'band': length 4 on <this-array> and length 19 on {'band': 'band', 'y': 'y', 'x': 'x'}

@ofcosar
Copy link
Author

ofcosar commented Mar 29, 2024

I discovered that the problem occurs when the date range is less than 12 months. How can we test our tif file that covers less than 12 months?

@gabrieltseng
Copy link
Collaborator

Hi @ofcosar - thanks for raising this! I am looking into it and can add a check that the tif file covers 12 months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants