crotwell / seisFile

A library for reading and writing seismic file formats in java.
GNU Lesser General Public License v3.0
27 stars 20 forks source link

Select Multiple Channels #27

Closed jsomeara closed 1 year ago

jsomeara commented 1 year ago

This works fine:

reader.select("UW", "LYNC", "", "HNE")

However, this does not:

reader.select("UW", "LYNC", "", "HNE HNN HNZ")

The above code returns:

Exception in thread "main" edu.sc.seis.seisFile.seedlink.SeedlinkException: Command SELECT HNE HNN HNZ.D did not return OK

Is it possible to select multiple channels?

crotwell commented 1 year ago

Two options, first is seedlink allows wildcards, so

reader.select("UW", "LYNC", "", "HN?")

Second option if wildcards are not sufficient is repeating the select command, like:

reader.select("UW", "LYNC", "", "HNE")
reader.select("UW", "LYNC", "", "HNN")
reader.select("UW", "LYNC", "", "HNZ")

Next version will have a couple of util methods to make this a bit easier.

jsomeara commented 1 year ago

Not 100% sure, but I recall trying the method with multiple .select statements and that only returned data from the last statement (ie. reader.select("UW", "LYNC", "", "HNZ"))

Once again, correct me if I'm wrong here.

crotwell commented 1 year ago

Digging in a bit more, the issue is with the empty location code. The code tries to put in a default wildcard of "??" for empty location codes, but this prevents channels with no location code from matching. Seedlink seems to not allow * as a wildcard for location. Defaulting to empty spaces then doesn't match channels where location code is something like 00, so seems no good answer. If I had a dime for every time I have been bitten by empty location codes I would be a rich man...the worst idea in the history of seismic data formats. :(

For now you can do this:

reader.select("UW", "LYNC", "  ", "HNE");
reader.select("UW", "LYNC", "  ", "HNN");
reader.select("UW", "LYNC", "  ", "HNZ");

eg, set location code to two spaces. Tested and it will get data for LYNC.

Next version will allow you to do this, which generates commands that will avoid repeating the station command and allows explicit setting of the missing location code, which is probably better anyway.

reader.sendStation("UW","LYNC");
reader.sendSelect("HNZ");
reader.sendSelect("HNN");
reader.sendSelect("HNE");
jsomeara commented 1 year ago

Looks good. Thanks for the help!