[new] save filteroptions as strings in XML (untested)
This commit is contained in:
		
							parent
							
								
									ffa30e92e9
								
							
						
					
					
						commit
						5aef50f922
					
				| @ -1 +1 @@ | ||||
| 23ed-dirty | ||||
| ffa3-dirty | ||||
|  | ||||
| @ -16,7 +16,8 @@ from pylot.core.io.inputs import PylotParameter | ||||
| from pylot.core.io.location import create_event, \ | ||||
|     create_magnitude | ||||
| from pylot.core.pick.utils import select_for_phase | ||||
| from pylot.core.util.utils import getOwner, full_range, four_digits | ||||
| from pylot.core.util.utils import getOwner, full_range, four_digits, transformFilteroptions2String, \ | ||||
|     transformFilterString4Export, backtransformFilterString | ||||
| 
 | ||||
| 
 | ||||
| def add_amplitudes(event, amplitudes): | ||||
| @ -235,6 +236,7 @@ def picksdict_from_picks(evt): | ||||
|         network = pick.waveform_id.network_code | ||||
|         mpp = pick.time | ||||
|         spe = pick.time_errors.uncertainty | ||||
|         filter_id = backtransformFilterString(str(pick.filter_id.id)) | ||||
|         try: | ||||
|             picker = str(pick.method_id) | ||||
|             if picker.startswith('smi:local/'): | ||||
| @ -261,6 +263,7 @@ def picksdict_from_picks(evt): | ||||
|         phase['channel'] = channel | ||||
|         phase['network'] = network | ||||
|         phase['picker'] = picker | ||||
|         phase['filter_id'] = filter_id if filter_id is not None else '' | ||||
| 
 | ||||
|         onsets[pick.phase_hint] = phase.copy() | ||||
|         picksdict[picker][station] = onsets.copy() | ||||
| @ -312,6 +315,13 @@ def picks_from_picksdict(picks, creation_info=None): | ||||
|             pick.waveform_id = ope.WaveformStreamID(station_code=station, | ||||
|                                                     channel_code=ccode, | ||||
|                                                     network_code=ncode) | ||||
|             try: | ||||
|                 filter_id = phase['filteroptions'] | ||||
|                 filter_id = transformFilterString4Export(filter_id) | ||||
|             except KeyError as e: | ||||
|                 warnings.warn(e.message, RuntimeWarning) | ||||
|                 filter_id = '' | ||||
|             pick.filter_id = filter_id | ||||
|             try: | ||||
|                 polarity = phase['fm'] | ||||
|                 if polarity == 'U' or '+': | ||||
| @ -328,7 +338,6 @@ def picks_from_picksdict(picks, creation_info=None): | ||||
|             picks_list.append(pick) | ||||
|     return picks_list | ||||
| 
 | ||||
| 
 | ||||
| def reassess_pilot_db(root_dir, db_dir, out_dir=None, fn_param=None, verbosity=0): | ||||
|     import glob | ||||
| 
 | ||||
|  | ||||
| @ -391,6 +391,38 @@ def full_range(stream): | ||||
|     return min_start, max_end | ||||
| 
 | ||||
| 
 | ||||
| def transformFilteroptions2String(filtopts): | ||||
|     st = '' | ||||
|     if not filtopts: | ||||
|         return st | ||||
|     if 'type' in filtopts.keys(): | ||||
|         st += '{}'.format(filtopts['type']) | ||||
|         if 'freq' in filtopts.keys(): | ||||
|             st += ' | freq: {}'.format(filtopts['freq']) | ||||
|         elif 'freqmin' in filtopts.keys() and 'freqmax' in filtopts.keys(): | ||||
|             st += ' | freqmin: {} | freqmax: {}'.format(filtopts['freqmin'], filtopts['freqmax']) | ||||
|     for key, value in filtopts.items(): | ||||
|         if key in ['type', 'freq', 'freqmin', 'freqmax']: | ||||
|             continue | ||||
|         st += ' | {}: {}'.format(key, value) | ||||
|     return st | ||||
| 
 | ||||
| 
 | ||||
| def transformFilterString4Export(st): | ||||
|     st = st.replace('|', '//') | ||||
|     st = st.replace(':', '/') | ||||
|     st = st.replace(' ', '') | ||||
|     return st | ||||
| 
 | ||||
| 
 | ||||
| def backtransformFilterString(st): | ||||
|     st = st.split('smi:local/') | ||||
|     st = st[1] if len(st) > 1 else st[0] | ||||
|     st = st.replace('//', ' | ') | ||||
|     st = st.replace('/', ': ') | ||||
|     return st | ||||
| 
 | ||||
| 
 | ||||
| def getHash(time): | ||||
|     """ | ||||
|     takes a time object and returns the corresponding SHA1 hash of the formatted date string | ||||
|  | ||||
| @ -17,8 +17,6 @@ import time | ||||
| import numpy as np | ||||
| 
 | ||||
| from matplotlib.figure import Figure | ||||
| from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components, \ | ||||
|     identifyPhaseID, check4rotated, real_Bool, pick_color | ||||
| 
 | ||||
| try: | ||||
|     from matplotlib.backends.backend_qt4agg import FigureCanvas | ||||
| @ -49,7 +47,9 @@ from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \ | ||||
|     SetChannelComponents | ||||
| from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \ | ||||
|     demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt, \ | ||||
|     check4rotated, check4doubled, check4gaps, remove_underscores | ||||
|     check4rotated, check4doubled, check4gaps, remove_underscores, find_horizontals, identifyPhase, \ | ||||
|     loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \ | ||||
|     identifyPhaseID, real_Bool, pick_color | ||||
| from autoPyLoT import autoPyLoT | ||||
| from pylot.core.util.thread import Thread | ||||
| 
 | ||||
| @ -1989,7 +1989,8 @@ class PickDlg(QDialog): | ||||
|         # save pick times for actual phase | ||||
|         phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, | ||||
|                           picker='manual', channel=channel, | ||||
|                           network=wfdata[0].stats.network) | ||||
|                           network=wfdata[0].stats.network, | ||||
|                           filteroptions=transformFilteroptions2String(filteroptions)) | ||||
| 
 | ||||
|         try: | ||||
|             oldphasepick = self.picks[phase] | ||||
| @ -2202,11 +2203,8 @@ class PickDlg(QDialog): | ||||
|                 data.detrend('linear') | ||||
|                 data.taper(0.02, type='cosine') | ||||
|                 data.filter(**filtoptions) | ||||
|                 title += ' | {} filtered |'.format(filtoptions['type']) | ||||
|                 for key, value in filtoptions.items(): | ||||
|                     if key == 'type': | ||||
|                         continue | ||||
|                     title += ' {}: {} |'.format(key, value) | ||||
|                 filtops_str = transformFilteroptions2String(filtoptions) | ||||
|                 title += ' | Filteroptions: {}'.format(filtops_str) | ||||
|         self.multicompfig.plotWFData(wfdata=data, title=title, | ||||
|                                      zoomx=self.getXLims(), | ||||
|                                      zoomy=self.getYLims()) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user