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

it seems the climatology file in the evaluation.ipynb quick setup guide seems to be missing #214

Closed
ShileiCao opened this issue Dec 9, 2024 · 3 comments

Comments

@ShileiCao
Copy link

FileNotFoundError: No such file or directory: 'gs://weatherbench2/datasets/era5-hourly-climatology/1990-2019_6h_64x32_equiangular_conservative.zarr'

@ShileiCao
Copy link
Author

ShileiCao commented Dec 9, 2024

when i replace it with “with_poles”, the file can be read. But it went wrong when I run the evaluation:

evaluate_in_memory(data_config, eval_configs)


ValueError Traceback (most recent call last)
in <cell line: 1>()
----> 1 evaluate_in_memory(data_config, eval_configs) # Takes around 5 minutes

9 frames
/usr/local/lib/python3.10/dist-packages/weatherbench2/evaluation.py in evaluate_in_memory(data_config, eval_configs, skipna)
515 """
516 for eval_name, eval_config in eval_configs.items():
--> 517 _evaluate_all_metrics(eval_name, eval_config, data_config, skipna=skipna)
518
519

/usr/local/lib/python3.10/dist-packages/weatherbench2/evaluation.py in _evaluate_all_metrics(eval_name, eval_config, data_config, skipna)
475 truth = truth.sel(time=forecast.valid_time)
476
--> 477 results = _metric_and_region_loop(forecast, truth, eval_config, skipna=skipna)
478
479 logging.info(f'Logging Evaluation complete:\n{results}')

/usr/local/lib/python3.10/dist-packages/weatherbench2/evaluation.py in _metric_and_region_loop(forecast, truth, eval_config, skipna, compute_chunk)
421 [region_name], coords={'region': [region_name]}
422 )
--> 423 tmp_result = eval_fn(
424 forecast=forecast, truth=truth, region=region, skipna=skipna
425 )

/usr/local/lib/python3.10/dist-packages/weatherbench2/metrics.py in compute(self, forecast, truth, region, skipna)
131 f"Forecast has neither valid_time or init_time dimension {forecast}"
132 )
--> 133 return self.compute_chunk(
134 forecast, truth, region=region, skipna=skipna
135 ).mean(

/usr/local/lib/python3.10/dist-packages/weatherbench2/metrics.py in compute_chunk(self, forecast, truth, region, skipna)
405 forecast_anom = forecast - climatology_chunk
406 truth_anom = truth - climatology_chunk
--> 407 return _spatial_average(
408 forecast_anom * truth_anom,
409 region=region,

/usr/local/lib/python3.10/dist-packages/weatherbench2/metrics.py in _spatial_average(dataset, region, skipna)
154 dataset: Spatially averaged metric.
155 """
--> 156 weights = get_lat_weights(dataset)
157 if region is not None:
158 dataset, weights = region.apply(dataset, weights)

/usr/local/lib/python3.10/dist-packages/weatherbench2/metrics.py in get_lat_weights(ds)
57 weights = _cell_area_from_latitude(np.deg2rad(ds.latitude.data))
58 weights /= np.mean(weights)
---> 59 weights = ds.latitude.copy(data=weights)
60 return weights
61

/usr/local/lib/python3.10/dist-packages/xarray/core/dataarray.py in copy(self, deep, data)
1300 pandas.DataFrame.copy
1301 """
-> 1302 return self._copy(deep=deep, data=data)
1303
1304 def _copy(

/usr/local/lib/python3.10/dist-packages/xarray/core/dataarray.py in _copy(self, deep, data, memo)
1308 memo: dict[int, Any] | None = None,
1309 ) -> Self:
-> 1310 variable = self.variable._copy(deep=deep, data=data, memo=memo)
1311 indexes, index_vars = self.xindexes.copy_indexes(deep=deep)
1312

/usr/local/lib/python3.10/dist-packages/xarray/core/variable.py in _copy(self, deep, data, memo)
955 ndata = as_compatible_data(data)
956 if self.shape != ndata.shape: # type: ignore[attr-defined]
--> 957 raise ValueError(
958 f"Data shape {ndata.shape} must match shape of object {self.shape}" # type: ignore[attr-defined]
959 )

ValueError: Data shape (1,) must match shape of object (0,)

@raspstephan
Copy link
Collaborator

Thank you for noticing. Yes, the 64x32 files in the bucket are wrong (they should be without poles). I just started the upload for the correct files but it might take a few hours. I will then also delete the 64x32 files with poles. Please let me know if it works now.

@ShileiCao
Copy link
Author

ShileiCao commented Dec 12, 2024

Thanks for fixing that.
But there is a small error in the beginning when import the apache_beam. It seems to be due to a problem with the pandas version.


TypeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 import apache_beam

11 frames
/usr/local/lib/python3.10/dist-packages/apache_beam/init.py in
85 import apache_beam.internal.pickler
86
---> 87 from apache_beam import coders
88 from apache_beam import io
89 from apache_beam import metrics

/usr/local/lib/python3.10/dist-packages/apache_beam/coders/init.py in
15 # limitations under the License.
16 #
---> 17 from apache_beam.coders.coders import *
18 from apache_beam.coders.row_coder import *
19 from apache_beam.coders.typecoders import registry

/usr/local/lib/python3.10/dist-packages/apache_beam/coders/coders.py in
57 import proto
58
---> 59 from apache_beam.coders import coder_impl
60 from apache_beam.coders.avro_record import AvroRecord
61 from apache_beam.portability import common_urns

/usr/local/lib/python3.10/dist-packages/apache_beam/coders/coder_impl.cpython-310-x86_64-linux-gnu.so in init apache_beam.coders.coder_impl()

/usr/local/lib/python3.10/dist-packages/apache_beam/typehints/init.py in
29 pass
30 else:
---> 31 from apache_beam.typehints.pandas_type_compatibility import *
32
33 try:

/usr/local/lib/python3.10/dist-packages/apache_beam/typehints/pandas_type_compatibility.py in
90 ]
91
---> 92 PANDAS_TO_BEAM = {
93 pd.Series([], dtype=dtype).dtype: fieldtype
94 for dtype,

/usr/local/lib/python3.10/dist-packages/apache_beam/typehints/pandas_type_compatibility.py in (.0)
91
92 PANDAS_TO_BEAM = {
---> 93 pd.Series([], dtype=dtype).dtype: fieldtype
94 for dtype,
95 fieldtype in _BIDIRECTIONAL

/usr/local/lib/python3.10/dist-packages/pandas/core/series.py in init(self, data, index, dtype, name, copy, fastpath)
582 data = data.copy()
583 else:
--> 584 data = sanitize_array(data, index, dtype, copy)
585
586 manager = _get_option("mode.data_manager", silent=True)

/usr/local/lib/python3.10/dist-packages/pandas/core/construction.py in sanitize_array(data, index, dtype, copy, allow_2d)
594 _sanitize_non_ordered(data)
595 cls = dtype.construct_array_type()
--> 596 subarr = cls._from_sequence(data, dtype=dtype, copy=copy)
597
598 # GH#846

/usr/local/lib/python3.10/dist-packages/pandas/core/arrays/masked.py in _from_sequence(cls, scalars, dtype, copy)
150 @classmethod
151 def _from_sequence(cls, scalars, *, dtype=None, copy: bool = False) -> Self:
--> 152 values, mask = cls._coerce_to_array(scalars, dtype=dtype, copy=copy)
153 return cls(values, mask)
154

/usr/local/lib/python3.10/dist-packages/pandas/core/arrays/boolean.py in _coerce_to_array(cls, value, dtype, copy)
354 if dtype:
355 assert dtype == "boolean"
--> 356 return coerce_to_array(value, copy=copy)
357
358 def _logical_method(self, other, op):

/usr/local/lib/python3.10/dist-packages/pandas/core/arrays/boolean.py in coerce_to_array(values, mask, copy)
198 integer_like = ("floating", "integer", "mixed-integer-float")
199 if inferred_dtype not in ("boolean", "empty") + integer_like:
--> 200 raise TypeError("Need to pass bool-like values")
201
202 # mypy does not narrow the type of mask_values to npt.NDArray[np.bool_]

TypeError: Need to pass bool-like values

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