Skip to content

Add a create-imdb stage collecting intensity measures into an IMDB - #230

Open
lispandfound wants to merge 3 commits into
pegasusfrom
imdb-stage
Open

lispandfound wants to merge 3 commits into
pegasusfrom
imdb-stage

Conversation

@lispandfound

Copy link
Copy Markdown
Contributor

create-imdb builds an IMDB (ucgmsim-imdb) from im-calc intensity measure files alone: simulated records per station and component, and gmm records per station, ground motion model and component. Observations are not included. Realisations named like clones (<event>_R<n>) are grouped into their event. Simulated records inside SW4's absorbing layer are left out.

im-calc now records the component of each empirical estimate, always writes site parameters, and always writes the supergrid coordinates (NaN where the solver does not report them).

Requires pandas 3 through ucgmsim-imdb, so velocity-modelling is raised to 2026.10.2, which drops its pandas<3 cap.

lispandfound and others added 2 commits October 21, 2026 14:12
create-imdb builds an IMDB (ucgmsim-imdb) from im-calc intensity measure
files alone: simulated records per station and component, and gmm records
per station, ground motion model and component. Observations are not
included. Realisations named like clones (`<event>_R<n>`) are grouped into
their event. Simulated records inside SW4's absorbing layer are left out.

im-calc now records the component of each empirical estimate, always
writes site parameters, and always writes the supergrid coordinates (NaN
where the solver does not report them).

Requires pandas 3 through ucgmsim-imdb, so velocity-modelling is raised to
2026.10.2, which drops its pandas<3 cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +139 to +161
def read_stations(dtree: xr.DataTree) -> pd.DataFrame:
"""Read the per-station parameters `im-calc` attaches to every IM.

Parameters
----------
dtree : xr.DataTree
The intensity measure tree.

Returns
-------
pd.DataFrame
The station location, site parameters, distances and absorbing layer
penetration, indexed by station name.
"""
dataset = next(node.dataset for node in dtree.subtree if node.has_data)
return pd.DataFrame(
{
name: coordinate.values
for name, coordinate in dataset.coords.items()
if coordinate.dims == ("station",) and name != "station"
},
index=pd.Index(dataset.station.values, name="station"),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xarray has a builtin for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to dataset.coords.to_dataset().drop_dims(...).to_dataframe() in 4452e48.

…matting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant