📄 masterview.java
字号:
report ("Getting Phase data.", 10);
loadPhases();
// load amps for magnitude of the sols
report ("Getting Amp data.", 20);
loadAmplitudes();
// load amps for magnitude of the sols
report ("Getting Coda data.", 30);
loadCodas();
// Make a local phase and amp lists for each WFView.
makeLocalLists();
}
/**
* Build a MasterView based on this solution containing stations within the
* parameter bounds and with waveforms with timespan defined as a window
* 'preOT' seconds before and 'postOT' seconds after the origin time of the
* solution. The view is NOT based on waveforms saved in the
* DataSource. Rather Waveform objects are created based on the TimeSpan
* given. These are effectively 'requests' that may or may not be
* successfully fulfilled when a call to loadWaveforms() is made. The
* DataSource will be searced for the TimeSpan specified to find phases,
* amps, etc. <p>
*
* The list will end at either the distance cutoff or the station count,
* whichever comes first. For example, assume there are 50 channels within
* 100 km of the epicenter; if distCutoff=100 & maxCount=20, only the
* nearest 20 channels will be included. If distCutoff=100 & maxCount=200,
* only the 50 stations within 100 km will be include. The station list
* comes from the Channel class. */
public void defineByParameters(Solution sol, double distCutoff, int maxCount,
double preOT, double postOT) {
if (sol != null ) {
double ot = sol.datetime.doubleValue();
TimeSpan ts = new TimeSpan (ot - preOT, ot + postOT);
defineByParameters(sol, distCutoff, maxCount, ts);
}
}
/**
* Build a MasterView based on this solution ID containing stations within
* the parameter bounds and with waveforms with this timespan. The view is
* NOT based on waveforms saved in the DataSource. Rather Waveform objects
* are created based on the TimeSpan given. These are effectively 'requests'
* that may or may not be successfully fulfilled when a call to
* loadWaveforms() is made. The DataSource will be searced for the TimeSpan
* specified to find phases, amps, etc. <p>
*
* The list will end at either the distance cutoff or the station count,
* whichever comes first. For example, assume there are 50 channels within
* 100 km of the epicenter; if distCutoff=100 & maxCount=20, only the
* nearest 20 channels will be included. If distCutoff=100 & maxCount=200,
* only the 50 stations within 100 km will be include. The station list
* comes from the Channel class. */
public void defineByParameters(long evid, double distCutoff, int maxCount,
TimeSpan ts) {
Solution sol = Solution.create().getById(evid);
if (sol != null ) defineByParameters(sol, distCutoff, maxCount, ts);
}
/** Define MasterView to includ all channels with readings; phases, amps or
* codas.
* This is used to construct a MasterView that does
* not depend on the waveforms windows that were assigned to this event by the
* data source. It does NOT load time series. */
public void defineByReadings (Solution sol,
double distCutoff, int maxCount,
TimeSpan ts) {
if (sol == null) return;
// adds sol to list in proper time order, notifies observers
addSolution(sol);
setSelectedSolution(sol);
// Set ALL views + master view to the time window passed in the arg
setAllViewSpans(ts);
loadReadings();
// create a WFView for each channel with a reading
insureReadingsHaveViews(true);
// match channels info
loadChannelData();
// calc distances and sort by dist from selected Solution
distanceSort();
// toss out-of-bounds views
wfvList.trim(maxCount);
wfvList.trim(distCutoff);
// create waveform time windows from scratch NOT from the data source
// (time-series are NOT loaded yet)
WFView wfv[] = wfvList.getArray();
for ( int i=0; i < wfv.length; i++) {
Waveform wf = Waveform.create();
wf.setChannelObj(wfv[i].chan);
wf.setTimeSpan(ts);
wfv[i].setWaveform( wf );
}
}
/** Define MasterView to includ all channels with phases.
* This is used to construct a MasterView that does
* not depend on the waveforms windows that were assigned to this event by the
* data source. It does NOT load time series. */
public void defineByPhaseList (Solution sol,
double distCutoff, int maxCount,
TimeSpan ts) {
if (sol == null) return;
// adds sol to list in proper time order, notifies observers
addSolution(sol);
setSelectedSolution(sol);
// Set ALL views + master view to the time window passed in the arg
setAllViewSpans(ts);
loadPhases();
// create a WFView for each channel with a reading
insureReadingsHaveViews(true);
// match channels info
loadChannelData();
// calc distances and sort by dist from selected Solution
distanceSort();
// toss out-of-bounds views
wfvList.trim(maxCount);
wfvList.trim(distCutoff);
// create waveform time windows from scratch NOT from the data source
// (time-series are NOT loaded yet)
WFView wfv[] = wfvList.getArray();
for ( int i=0; i < wfv.length; i++) {
Waveform wf = Waveform.create();
wf.setChannelObj(wfv[i].chan);
wf.setTimeSpan(ts);
wfv[i].setWaveform( wf );
}
}
/**
* Create a MasterView based on the Waveforms associated with this Solution in
* the DataSource. Load the phase, amp, etc. */
/* public boolean defineByChannelTimeWindowModel(ChannelTimeWindowModel model,
double distCutoff, int maxCount) {
if (defineByChannelTimeWindowModel(model)) {
// toss out-of-bounds views
wfvList.trim(maxCount);
wfvList.trim(distCutoff);
return true;
}
return false;
}
*/
/**
* Set MasterView's default ChannelTimeWindowModel.
* */
public void setChannelTimeWindowModel(ChannelTimeWindowModel model) {
defaultChannelTimeWindowModel = model;
// defaultChannelTimeWindowModel.setChannelList(MasterChannelList.get());
// DDG 10/11/02 test
defaultChannelTimeWindowModel.setChannelList(null);
}
/**
* Get MasterView's default ChannelTimeWindowModel.
* */
public ChannelTimeWindowModel getChannelTimeWindowModel() {
return defaultChannelTimeWindowModel;
}
/**
* Create a MasterView based the default ChannelTimeWindowModel and the currently
* selected Solution. Returns true on success. */
public boolean defineByChannelTimeWindowModel() {
if (this.getSelectedSolution() == null) return false;
// defaultChannelTimeWindowModel.setChannelList(MasterChannelList.get());
// DDG 10/11/02 test
defaultChannelTimeWindowModel.setChannelList(null);
return defineByChannelTimeWindowModel(defaultChannelTimeWindowModel,
this.getSelectedSolution());
}
/**
* Create a MasterView based this model and event ID number. Loads the phases, amps, etc.
* The Solution created for this 'evid' will be added to the MasterView and set
* as the selected Solution.
* Returns true on success. */
public boolean defineByChannelTimeWindowModel(ChannelTimeWindowModel model, long evid) {
Solution sol = Solution.create();
sol.getById(evid);
if (sol == null) return false;
addSolution(sol);
setSelectedSolution(sol);
return defineByChannelTimeWindowModel(model, sol);
}
/**
* Create a MasterView based this model and Solution. Loads the phases, amps, etc.
* Returns true on success. */
public boolean defineByChannelTimeWindowModel(ChannelTimeWindowModel model, Solution sol) {
model.setSolution(sol);
return defineByChannelTimeWindowModel(model);
}
/**
* Create a MasterView based this model. Loads the phases, amps, etc. Note that
* the solution must be set for the model.
* The currently selected solution of the MasterView will be used as the model's
* Solution.
* Returns true on success. */
public boolean defineByChannelTimeWindowModel(ChannelTimeWindowModel model) {
Solution sol = getSelectedSolution();
// Gotta' have a Solution
if ( sol == null ) return false;
report("Getting waveform headers.", 20);
// Get Waveforms Header Info (time series is NOT loaded yet)
ArrayList wfa = (ArrayList) model.getWaveformList(sol);
if (debug) System.out.println ("Number of available waveforms = "+wfa.size());
// Create a WFView for each waveform found for this event
if (wfa.size() > 0) {
report("Making Waveform views.", 0);
// start with a clean WFViewList. Can't just abandon the old reference and
// instatiate a new one because the Waveform listeners would still have
// a reference and never garbage collect.
wfvList.clear();
// Add these WFViews to this MasterView (would getting an array be faster here?)
int counter = 0;
int inc = 100/wfa.size();
int done = 0;
for (int i = 0; i<wfa.size(); i++) {
this.addWFView(new WFView( (Waveform) wfa.get(i)));
report (done);
done += inc;
}
} else {
report("No Waveform views defined.", 0);
}
// loads phases, amps and codas
loadReadings();
// create a WFView for each channel with a reading
insureReadingsHaveViews(true);
// copy lat/lon info from Channel class to WFViews
report ("Loading channel data.", 0);
loadChannelData();
// calc distances and sort by dist from selected Solution
distanceSort(sol);
alignViews();
// Get timeseries if flag is set
loadWaveforms();
return true;
}
/**
* Create a MasterView based on a ChannelTimeWindow List. */
public boolean defineByChannelTimeWindowList(Collection ctwList) {
// Create a WFView for each waveform found for this event
if (ctwList.size() > 0) {
// Get Waveforms Header Info (time series is NOT loaded yet)
ChannelTimeWindow ctw[] = (ChannelTimeWindow[]) ctwList.toArray(new ChannelTimeWindow[0]);
report("Making Waveform views.", 0);
// start with a clean WFViewList. Used to just make a new make a new wfvList
// but that killed the Waveform listeners that inform when they are loaded
// to repaint WFPanel.
wfvList.clear();
// Add these WFViews to this MasterView (would getting an array be faster here?)
int counter = 0;
int inc = 100/ctw.length;
int done = 0;
WFView wfv;
TimeSpan ts;
for (int i = 0; i<ctw.length; i++) {
ts = new TimeSpan(ctw[i].getStart(), ctw[i].getEnd());
wfv = new WFView(ctw[i].getChannelObj(), ts);
// wfv.setWaveform(new Waveform (ctw[i].chan, ts));
Waveform wf = Waveform.create();
wf.setChannelObj(ctw[i].getChannelObj());
wf.setTimeSpan(ts);
wfv.setWaveform( wf );
addWFView(wfv);
report (done);
done += inc;
}
}
loadChannelData();
// Make a local phase and amp lists for each WFView.
makeLocalLists();
alignViews();
// Get timeseries if flag is set
loadWaveforms();
return true;
}
/**
* Create a MasterView based on TriggerChannelTimeWindows list. Trigger times will create
* phases. */
public boolean defineByTriggerChannelTimeWindowList(Collection ctwList) {
// Create a WFView for each waveform found for this event
if (ctwList.size() > 0) {
// Get Waveforms Header Info (time series is NOT loaded yet)
TriggerChannelTimeWindow ctw[] =
(TriggerChannelTimeWindow[]) ctwList.toArray(new TriggerChannelTimeWindow[0]);
report("Making Waveform views.", 0);
// start with a clean WFViewList. Used to just make a new make a new wfvList
// but that killed the Waveform listeners that inform when they are loaded
// to repaint WFPanels.
wfvList.clear();
// Add these WFViews to this MasterView (would getting an array be faster here?)
int counter = 0;
int inc = 100/ctw.length;
int done = 0;
WFView wfv;
TimeSpan ts;
for (int i = 0; i<ctw.length; i++) {
ts = new TimeSpan(ctw[i].getStart(), ctw[i].getEnd());
wfv = new WFView(ctw[i].getChannelObj(), ts);
// wfv.setWaveform(new Waveform (ctw[i].chan, ts));
Waveform wf = Waveform.create();
wf.setChannelObj(ctw[i].getChannelObj());
wf.setTimeSpan(ts);
wfv.setWaveform( wf );
addWFView(wfv);
// Interpret the trigger time as a P-phase so a pick marker will be plotted
if (ctw[i].triggerTime != 0.0) {
Phase ph = Phase.create();
ph.setChannelObj(ctw[i].getChannelObj());
ph.setTime(ctw[i].triggerTime);
ph.description = new PhaseDescription("T", "x", " ", 4);
addPhaseToCurrentSolution(ph);
}
report (done);
done += inc;
}
}
loadChannelData();
// Make a local phase and amp lists for each WFView.
makeLocalLists();
alignViews();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -