Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix stationxml extras - #3588

Open
ThomasLecocq wants to merge 10 commits into
masterfrom
fix_stationxml_extras
Open

Fix stationxml extras#3588
ThomasLecocq wants to merge 10 commits into
masterfrom
fix_stationxml_extras

Conversation

@ThomasLecocq

@ThomasLecocq ThomasLecocq commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

  1. Extra elements added to Equipment or Sensors (or probably others) got attached to the wrong (parent) node when writing.

Solved.
TODO:

  • add a test case for each "level", currently only Sensors are tested, I believe.
  1. The root namespaces definitions were not passed to the writing method

It was possible to pass nsmap={key:address} to the write() method (kwarg was passed to _write_stationxml) but it's not obvious why that couldn't be automatically populated when the inventory was read with a ns in it. The implementation now stores the namespace dictionnary into the Inventory._namespaces and if the write method is called without nsmap, it'll first try to get it from the inventory, then fall back to an empty dict if not available.

Why was it initiated? Any relevant Issues?

Ref: Issue #3574
Tested on the provided file, which is also now included in the io/stationxml/tests/data

PR Checklist

  • Correct base branch selected? master for new features, maintenance_... for bug fixes
  • This PR is not directly related to an existing issue (which has no PR yet).
  • While the PR is still work-in-progress, the no_ci label can be added to skip CI builds
  • All tests still pass. on my machine!, CI looks broken.
  • Any new features or fixed regressions are covered via new tests.
  • Any new or changed features are fully documented.
  • Significant changes have been added to CHANGELOG.txt .
  • Add the yellow ready for review label when you are ready for the PR to be reviewed.

@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

@nick-falco you were the one coding that extra thing ? 😇

@ThomasLecocq ThomasLecocq added the ready for review PRs that are ready to be reviewed to get marked ready to merge label Jul 24, 2025
@ThomasLecocq ThomasLecocq linked an issue Jul 25, 2025 that may be closed by this pull request
@ThomasLecocq

ThomasLecocq commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

on my machine all tests pass, including doctests. So I suppose it's again a change on the way doctests prints are compared?

https://tests.obspy.org/144878/

The shapefile-related issues are linked to #3599 (pyshp version 3.0 just rolled out).

@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

In brief: should be 💚 light to review & merge. @WayneCrawford

@nick-falco

Copy link
Copy Markdown
Member

@nick-falco you were the one coding that extra thing ? 😇

Hey @ThomasLecocq. I've been pretty out of the loop with this for several years now, as I no longer work at IRIS. I would need to be brought up to speed with what you're trying to accomplish.

@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

@nick-falco hehe no worries. I checked the "git blame" of the lines added to support the extra namespace + fields and found yours :) I think this PR covers all cases now, but I don't have a complete test with namespaced' items for each item, would you know where to find that ?

@ThomasLecocq ThomasLecocq added this to the 1.5.0 milestone Aug 19, 2025
@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

@crotwell @chad-earthscope @jschaeff do you have a stationXML with ALL possible cases populated? It'd be good to add to our test data - so we could verify this PR solves namespace issues? -- or if you really really want, you can take over this PR :-)

@crotwell

Copy link
Copy Markdown
Contributor

I assume you are aware of the examples in the StationXML repo,
https://github.com/FDSN/StationXML/tree/main/docs/examples

Beyond that, I don't have anything beyond what you can get from queries to the FDSN Station webservices.

If you do find a comprehensive example, it might be nice to have it in the stationxml repo for furture testing purposes.

@chad-earthscope

Copy link
Copy Markdown
Contributor

do you have a stationXML with ALL possible cases populated?

I do not. they are, by their nature I think, ad hoc and institution/domain specific.

@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

thanks for your inputs. I'm really not knowledgeable on xml and their xsd, but would it be possible to "create" a dummy XML file that has "every" elements (even optional ones) based on the xsd ?

For this PR, I'll wait for the input from @WayneCrawford too.

@filefolder

filefolder commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

FWIW tried to AI (warning!!!) a full example stationXML based on the published FDSN 1.2 xsd.. had to fix a few items but looks pretty good, or at least decent a starting point. (Currently doing similar work trying to map QuakeML to a pandas dataframe but that's another issue- edit I see this is already done yay)

example_fdsnstation1.2.fdsnxml.txt

and now with all possible custom namespaces filled in
example_namespaces_fdsnstation1.2.fdsnxml.txt

@d-chambers

Copy link
Copy Markdown
Member

Currently doing similar work trying to map QuakeML to a pandas dataframe but that's another issue

Hey @filefolder, unrelated to this PR, but for what is worth ObsPlus does this, although perhaps not perfectly. Here are some examples.

@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

FWIW tried to AI (warning!!!) a full example stationXML based on the published FDSN 1.2 xsd.. had to fix a few items but looks pretty good, or at least decent a starting point. (Currently doing similar work trying to map QuakeML to a pandas dataframe but that's another issue- edit I see this is already done yay)

example_fdsnstation1.2.fdsnxml.txt

looks good, but lacks the optional namespace attributes (namespace declared at the top of the file, then Elements are namespace:Type where possible (Equipment, etc)

@filefolder

Copy link
Copy Markdown
Contributor

FWIW tried to AI (warning!!!) a full example stationXML based on the published FDSN 1.2 xsd.. had to fix a few items but looks pretty good, or at least decent a starting point. (Currently doing similar work trying to map QuakeML to a pandas dataframe but that's another issue- edit I see this is already done yay)
example_fdsnstation1.2.fdsnxml.txt

looks good, but lacks the optional namespace attributes (namespace declared at the top of the file, then Elements are namespace:Type where possible (Equipment, etc)

Ah right.. the whole point of this. I chucked in an addition version "for research purposes only". It is supposed to have xyz namespace elements in all the places the XSD allows.. but of course buyer be very aware

@ThomasLecocq ThomasLecocq modified the milestones: 1.5.0, Future release Dec 2, 2025
@ThomasLecocq ThomasLecocq added author action needed and removed ready for review PRs that are ready to be reviewed to get marked ready to merge labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correctly handle external namespaces in StationXML files

6 participants