def test_channel_str(self): """ Tests the __str__ method of the channel object. """ c = Channel(code="BHE", location_code="10", latitude=1, longitude=2, elevation=3, depth=4, azimuth=5, dip=6) assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n") # Adding channel types. c.types = ["A", "B"] assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n") # Adding channel types. c.sample_rate = 10.0 assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n") # "Adding" response c.response = True assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tResponse information available") # Adding an empty sensor. c.sensor = Equipment(type=None) assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): None (None)\n" "\tResponse information available") # Adding a sensor with only a type. c.sensor = Equipment(type="random") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): random (None)\n" "\tResponse information available") # Adding a sensor with only a description c.sensor = Equipment(description="some description") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): None (some description)\n" "\tResponse information available") # Adding a sensor with type and description c.sensor = Equipment(type="random", description="some description") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): random (some description)\n" "\tResponse information available")
def test_channel_str(self): """ Tests the __str__ method of the channel object. """ c = Channel(code="BHE", location_code="10", latitude=1, longitude=2, elevation=3, depth=4, azimuth=5, dip=6) assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n") # Adding channel types. c.types = ["A", "B"] assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n") # Adding channel types. c.sample_rate = 10.0 assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n") # "Adding" response c.response = True assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tResponse information available" ) # Adding an empty sensor. c.sensor = Equipment(type=None) assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): None (None)\n" "\tResponse information available" ) # Adding a sensor with only a type. c.sensor = Equipment(type="random") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): random (None)\n" "\tResponse information available" ) # Adding a sensor with only a description c.sensor = Equipment(description="some description") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): None (some description)\n" "\tResponse information available" ) # Adding a sensor with type and description c.sensor = Equipment(type="random", description="some description") assert str(c) == ( "Channel 'BHE', Location '10' \n" "\tTime range: -- - --\n" "\tLatitude: 1.00, Longitude: 2.00, Elevation: 3.0 m, " "Local Depth: 4.0 m\n" "\tAzimuth: 5.00 degrees from north, clockwise\n" "\tDip: 6.00 degrees down from horizontal\n" "\tChannel types: A, B\n" "\tSampling Rate: 10.00 Hz\n" "\tSensor (Description): random (some description)\n" "\tResponse information available" )
site=Site(name=station_df['siteID'])) for comp in ['ex', 'ey', 'hx', 'hy', 'hz']: if station_df['{0}_azm'.format(comp)] is not None: if 'h' in comp: cha = Channel(code=comp.upper(), location_code="", latitude=station_df['lat'], longitude=station_df['lon'], elevation=station_df['nm_elev'], depth=0, azimuth=station_df['{0}_azm'.format(comp)], dip=0, sample_rate=station_df['sampling_rate']) cha.channel_number = station_df['{0}_num'.format(comp)] cha.sensor = Equipment( serial_number=station_df['{0}_id'.format(comp)]) elif 'e' in comp: cha = Channel(code=comp.upper(), location_code="", latitude=station_df['lat'], longitude=station_df['lon'], elevation=station_df['nm_elev'], depth=0, azimuth=station_df['{0}_azm'.format(comp)], dip=0, sample_rate=station_df['sampling_rate']) cha.extra = {'dipole_length': {'value': 10, 'namespace': 'MT'}} # cha.comments = Comment(['Dipole Length (m) = {0:.1f}'.format(station_df['{0}_len'.format(comp)])]) sta.channels.append(cha) # Now tie it all together.