[minor] added verbosity flag for Metadata to reduce output in GUI
This commit is contained in:
parent
a85b79e432
commit
34891d3dc1
4
PyLoT.py
4
PyLoT.py
@ -118,7 +118,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.apw = None
|
self.apw = None
|
||||||
self.paraBox = None
|
self.paraBox = None
|
||||||
self.array_map = None
|
self.array_map = None
|
||||||
self._metadata = Metadata()
|
self._metadata = Metadata(verbosity=0)
|
||||||
self._eventChanged = [False, False]
|
self._eventChanged = [False, False]
|
||||||
self.apd_local = None
|
self.apd_local = None
|
||||||
self.apd_sge = None
|
self.apd_sge = None
|
||||||
@ -3153,7 +3153,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def init_metadata(self, new=False, ask_default=True):
|
def init_metadata(self, new=False, ask_default=True):
|
||||||
if hasattr(self.project, 'inventories'):
|
if hasattr(self.project, 'inventories'):
|
||||||
self.metadata = Metadata()
|
self.metadata = Metadata(verbosity=0)
|
||||||
for inventory in self.project.inventories:
|
for inventory in self.project.inventories:
|
||||||
self.metadata.add_inventory(inventory)
|
self.metadata.add_inventory(inventory)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from pylot.core.util.utils import key_for_set_value, find_in_list, \
|
|||||||
|
|
||||||
class Metadata(object):
|
class Metadata(object):
|
||||||
|
|
||||||
def __init__(self, inventory=None):
|
def __init__(self, inventory=None, verbosity=1):
|
||||||
self.inventories = []
|
self.inventories = []
|
||||||
# saves read metadata objects (Parser/inventory) for a filename
|
# saves read metadata objects (Parser/inventory) for a filename
|
||||||
self.inventory_files = {}
|
self.inventory_files = {}
|
||||||
@ -27,6 +27,7 @@ class Metadata(object):
|
|||||||
self.add_inventory(inventory)
|
self.add_inventory(inventory)
|
||||||
if os.path.isfile(inventory):
|
if os.path.isfile(inventory):
|
||||||
self.add_inventory_file(inventory)
|
self.add_inventory_file(inventory)
|
||||||
|
self.verbosity = verbosity
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
repr = 'PyLoT Metadata object including the following inventories:\n\n'
|
repr = 'PyLoT Metadata object including the following inventories:\n\n'
|
||||||
@ -107,14 +108,16 @@ class Metadata(object):
|
|||||||
self._read_inventory_data(seed_id)
|
self._read_inventory_data(seed_id)
|
||||||
# if seed id is not found read all inventories and try to find it there
|
# if seed id is not found read all inventories and try to find it there
|
||||||
if not seed_id in self.seed_ids.keys():
|
if not seed_id in self.seed_ids.keys():
|
||||||
print('No data found for seed id {}. Trying to find it in all known inventories...'.format(seed_id))
|
if self.verbosity:
|
||||||
|
print('No data found for seed id {}. Trying to find it in all known inventories...'.format(seed_id))
|
||||||
self.read_all()
|
self.read_all()
|
||||||
for inv_fname, metadata_dict in self.inventory_files.items():
|
for inv_fname, metadata_dict in self.inventory_files.items():
|
||||||
# use get_coordinates to check for seed_id
|
# use get_coordinates to check for seed_id
|
||||||
try:
|
try:
|
||||||
metadata_dict['data'].get_coordinates(seed_id, time)
|
metadata_dict['data'].get_coordinates(seed_id, time)
|
||||||
self.seed_ids[seed_id] = inv_fname
|
self.seed_ids[seed_id] = inv_fname
|
||||||
print('Found metadata for station {}!'.format(seed_id))
|
if self.verbosity:
|
||||||
|
print('Found metadata for station {}!'.format(seed_id))
|
||||||
return metadata_dict
|
return metadata_dict
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
continue
|
continue
|
||||||
@ -181,7 +184,7 @@ class Metadata(object):
|
|||||||
if not station_name in self.stations_dict.keys():
|
if not station_name in self.stations_dict.keys():
|
||||||
st_id = network_name + '.' + station_name
|
st_id = network_name + '.' + station_name
|
||||||
self.stations_dict[st_id] = {'latitude': station[0].latitude,
|
self.stations_dict[st_id] = {'latitude': station[0].latitude,
|
||||||
'longitude': station[0].longitude}
|
'longitude': station[0].longitude}
|
||||||
|
|
||||||
def stat_info_from_inventory(inventory):
|
def stat_info_from_inventory(inventory):
|
||||||
for network in inventory.networks:
|
for network in inventory.networks:
|
||||||
@ -241,7 +244,8 @@ class Metadata(object):
|
|||||||
# search for network name in filename
|
# search for network name in filename
|
||||||
fnames = glob.glob(os.path.join(path_to_inventory, '*' + network + '*'))
|
fnames = glob.glob(os.path.join(path_to_inventory, '*' + network + '*'))
|
||||||
if not fnames:
|
if not fnames:
|
||||||
print('Could not find filenames matching station name, network name or seed id')
|
if self.verbosity:
|
||||||
|
print('Could not find filenames matching station name, network name or seed id')
|
||||||
return
|
return
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
if fname in self.inventory_files.keys():
|
if fname in self.inventory_files.keys():
|
||||||
|
@ -143,7 +143,7 @@ class AddMetadataWidget(QWidget):
|
|||||||
self.connect_signals()
|
self.connect_signals()
|
||||||
self.resize(600, 800)
|
self.resize(600, 800)
|
||||||
|
|
||||||
self.metadata = metadata if metadata else Metadata()
|
self.metadata = metadata if metadata else Metadata(verbosity=0)
|
||||||
self.from_metadata()
|
self.from_metadata()
|
||||||
|
|
||||||
self.center()
|
self.center()
|
||||||
|
Loading…
Reference in New Issue
Block a user