def test_stationxml_is_valid(self): """ Make sure the generated stationxml files are actually valid. """ with io.BytesIO() as buf: buf.write(self.client.get( "/fdsnws/station/1/query?level=network").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write(self.client.get( "/fdsnws/station/1/query?level=station").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write(self.client.get( "/fdsnws/station/1/query?level=channel").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write(self.client.get( "/fdsnws/station/1/query?level=response").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0])
def test_stationxml_is_valid(self): """ Make sure the generated stationxml files are actually valid. """ with io.BytesIO() as buf: buf.write( self.client.get( "/fdsnws/station/1/query?level=network").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write( self.client.get( "/fdsnws/station/1/query?level=station").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write( self.client.get( "/fdsnws/station/1/query?level=channel").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0]) with io.BytesIO() as buf: buf.write( self.client.get( "/fdsnws/station/1/query?level=response").content) buf.seek(0, 0) self.assertTrue(validate_stationxml(buf)[0])
rs.input_units_description = "Digital Counts" #correct for Celsius (C) units name if rs.output_units == "C": rs.output_units = "CELSIUS" #will be degC in the future if rs.input_units == "C": rs.input_units = "CELSIUS" #will be degC in the future if channel.response.instrument_sensitivity.output_units == "COUNTS" or channel.response.instrument_sensitivity.output_units == "COUNT": channel.response.instrument_sensitivity.output_units = channel.response.instrument_sensitivity.output_units.lower( ) if channel.response.instrument_sensitivity.input_units == "COUNTS" or channel.response.instrument_sensitivity.input_units == "COUNT": channel.response.instrument_sensitivity.input_units = channel.response.instrument_sensitivity.input_units.lower( ) if channel.calibration_units == "COUNTS" or channel.calibration_units == "COUNT": channel.calibration_units = channel.calibration_units.lower( ) new_inv[0][k].channels.append(channel) print(new_inv) #%% Write the Inventory to StationXML print("Writing file.") new_inv.write(r"MetadataDrop\NV.xml", format="stationxml", validate=True) print("\n\nStationXML is valid? {}.".format( validate_stationxml('NV_StationXML.xml')[0])) if validate_stationxml('NV_StationXML.xml')[1] == (): print("\t - No errors were found.") else: print("Errors found: {}".format( validate_stationxml('NV_StationXML.xml')[1]))
'Device URL.') ]) if _channel.calibration_units == "COUNTS" or _channel.calibration_units == "COUNT": _channel.calibration_units = _channel.calibration_units.lower( ) _station.channels.append(_channel) print( "Channel {}.{} appended successfully to Inventory." .format(_channel_code, Channels[channel]['_location_code'])) except Exception as e: print( "Check that metadata assignments are correct for station: {}; {}" .format(station, e)) except: print("No epochs assigned to station: {}".format(station)) print("\n\n###\nInventory: \n", inv) # Write the Inventory to StationXML print("""\n\nWriting StationXML file to "{}".""".format(os.getcwd())) inv.write("NV_ONC.xml", format="stationxml", validate=True) from obspy.io.stationxml.core import validate_stationxml print("\n\nStationXML is valid? {}.".format( validate_stationxml('NV_ONC.xml')[0])) if validate_stationxml('NV_ONC.xml')[1] == (): print("\t - No errors were found.") else: print("Errors found: {}".format(validate_stationxml('NV_ONC.xml')[1]))
def validate(self, document): is_stationxml, error = validate_stationxml(document) if not is_stationxml: raise ValueError(error) return True