Somewhere in the recent flurry of changes made with the AI to fix some old problem an unexpected change happened. Previously the method Database.save_inventory saved the response data for a channel to an attribute with the key "serialized_channel_data". It still does that but the (default) format it uses changed completely. Previously the obspy Response object was serialized with pickle.dumps. It seems we now have a new module in mspasspy.db.serialization called encode_inventory. Apparently that converts the response data back to StationXML using an obspy function and saves that as the value associated with "serialized_channel_data". The new method to restore "serialized_channel_data" from a document in channel is this code snippet:
from mspasspy.db.serialization import decode_response
# example just pulling first document in channel
doc = db.channel.find_one()
response_doc = doc["serialized_channel_data"]
resp = decode_response(response_doc)
Poking around the code it seems there is some way to make the backward compatible to handle data stored previously with pickle. I haven't really dug into that as I don't think it is that important. I would always recommend most uses should use web services to build the channel metadata anyway to assure it is always as current as possible since thing do get changed there. The only way that would enter then is if reading old channel collection data saved in something like a json dump.
I am posting this as there are two things we need to do to follow up on this:
- I haven't checked but presume the user manual is out of date on this topic. Somewhere, I know, it discusses handling response data and the whole issue of using web services top populate the channel and site collections. We need to clean any misinformation there.
- The mspass_tutorials are a bigger problem as unless something was done there is misinformation there too.
The good news is it looks like the calib.py module addressed this change and that is not part of this issue. For the record, that comes up because the "calib" attribute to scale data from counts to nm/s is contained in the Response object that is created by decode_response. It appears that was changed when save_inventory was changed,
This not a high priority issue as it seems to be restricted to a documentation problem but we do need to address it at some point. For now just keeping it as an issue will address the misinformation.
Somewhere in the recent flurry of changes made with the AI to fix some old problem an unexpected change happened. Previously the method
Database.save_inventorysaved the response data for a channel to an attribute with the key "serialized_channel_data". It still does that but the (default) format it uses changed completely. Previously the obspy Response object was serialized with pickle.dumps. It seems we now have a new module inmspasspy.db.serializationcalledencode_inventory. Apparently that converts the response data back to StationXML using an obspy function and saves that as the value associated with "serialized_channel_data". The new method to restore "serialized_channel_data" from a document in channel is this code snippet:Poking around the code it seems there is some way to make the backward compatible to handle data stored previously with pickle. I haven't really dug into that as I don't think it is that important. I would always recommend most uses should use web services to build the channel metadata anyway to assure it is always as current as possible since thing do get changed there. The only way that would enter then is if reading old channel collection data saved in something like a json dump.
I am posting this as there are two things we need to do to follow up on this:
The good news is it looks like the calib.py module addressed this change and that is not part of this issue. For the record, that comes up because the "calib" attribute to scale data from counts to nm/s is contained in the Response object that is created by
decode_response. It appears that was changed whensave_inventorywas changed,This not a high priority issue as it seems to be restricted to a documentation problem but we do need to address it at some point. For now just keeping it as an issue will address the misinformation.