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

add model perturbation example #5

Merged
merged 9 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<!-- markdownlint-disable MD024 -->
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2024-04-XX
## [0.2.0] - 2024-xx-xx

### Added

- Initial Release of earth2studio
- SFNO model `sfno_73ch_small`.

### Changed

### Deprecated
Expand All @@ -23,3 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security

### Dependencies

## [0.1.0] - 2024-04-22

### Added

- Initial Release of earth2studio
2 changes: 1 addition & 1 deletion earth2studio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.1.0a0"
__version__ = "0.1.0"
22 changes: 15 additions & 7 deletions earth2studio/data/gfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,29 @@ def modifier(x: np.array) -> np.array:

return gfsda

def _validate_time(self, times: list[datetime]) -> None:
"""Verify if date time is valid for GFS
@classmethod
def _validate_time(cls, times: list[datetime]) -> None:
"""Verify if date time is valid for GFS based on offline knowledge

Parameters
----------
times : list[datetime]
list of date times to fetch data
"""
for time in times:
if not time.hour % 6 == 0:
if not time.hour % 6 == 0 or not time.minute == 0 or not time.second == 0:
raise ValueError(
f"Requested date time {time} needs to be 6 hour interval for GFS"
)
# To update search "gfs." at https://noaa-gfs-bdp-pds.s3.amazonaws.com/index.html
if time < datetime(year=2021, month=2, day=20):
# They are slowly adding more data
if time < datetime(year=2021, month=2, day=17):
raise ValueError(
f"Requested date time {time} needs to be after February 20th, 2021 for GFS"
f"Requested date time {time} needs to be after February 17th, 2021 for GFS"
)

if not self.available(time):
raise ValueError(f"Requested date time {time} not available in GFS")
# if not self.available(time):
# raise ValueError(f"Requested date time {time} not available in GFS")

def _fetch_index(self, time: datetime) -> dict[str, tuple[int, int]]:
"""Fetch GFS atmospheric index file
Expand Down Expand Up @@ -331,6 +333,12 @@ def available(
_ds = np.timedelta64(1, "s")
time = datetime.utcfromtimestamp((time - _unix) / _ds)

# Offline checks
try:
cls._validate_time([time])
except ValueError:
return False

s3 = boto3.client(
"s3", config=botocore.config.Config(signature_version=UNSIGNED)
)
Expand Down
2 changes: 1 addition & 1 deletion examples/02_ensemble_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Simple ensemble inference workflow.

This example will demonstrate how to run a simple inference workflow to generate a
simple ensemble forecast using one of the built in models of Earth-2 Inference
ensemble forecast using one of the built in models of Earth-2 Inference
Studio.

In this example you will learn:
Expand Down
Loading