Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/bandcode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Frequency Band Channel Code Guidelines

The first letter specifies the general sampling rate and the response band of the instrument. (The “A” code is reserved for
administrative functions such as miscellaneous state of health.)

|Band Code |Band Type |Sample Rate (Hz) |Corner Period (Sec) |
|---|---|---|---|
|F |... | $\geq$ 1000 to $\lt$ 5000|$\geq$ 10 sec|
|G |... | $\geq$ 1000 to $\lt$ 5000|$\lt$ 10 sec|
|D |... | $\geq$ 250 to $\lt$ 1000|$\lt$ 10 sec|
|C |... | $\geq$ 250 to $\lt$ 1000|$\geq$ 10 sec|
|E |Extremely Short Period|$\geq$ 80 to $\lt$ 250|$\lt$ 10 sec|
|S |Short Period |$\geq$ 10 to $\lt$ 80|$\lt$ 10 sec|
|H |High Broad Band |$\geq$ 80 to $\lt$ 250|$\geq$ 10 sec|
|B |Broad Band |$\geq$ 10 to $\lt$ 80|$\geq$ 10 sec|
|M |Mid Period |$\geq$ 1 to $\lt$ 10 | |
|L |Long Period |$\geq$ 0.1 to $\lt$ 10| |
|V |Very Long Period |$\geq$ 0.01 to $\lt$ 1| |
|U |Ultra Long Period |$\geq$ 0.001 to $\lt$ 0.1| |
|R |Extremely Long Period |$\geq$ 0.0001 to $\lt$ 0.001| |
|P |On the order of 0.1 to 1 day|$\geq$ 0.00001 to $\lt$ 0.0001| |
|T |On the order of 1 to 10 days|$\geq$ 0.000001 to $\lt$ 0.00001| |
|Q |Greater than 10 days| $\lt$ 0.000001 | |
|A |Administrative Instrument Channel|variable| NA |
|O |Opaque Instrument Channel|variable| NA|

[Updated 09-2020]
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The IRIS stationxml-validator is a Java library and related command-line utility
* [Validation tests](tests.md)
* [Unit name overview for IRIS stationxml-validator](units.md)
* [Rule restrictions](restrictions.md)
* [Band Code Dictionary](bandcode.md)
* [Channel:Code orthogonal orientation guidelines](orientation.md)
* [Contributing to the StationXML Validator](contribution.md)

Expand All @@ -21,6 +22,7 @@ If you wish to compile the program, the source code is available. Follow the [in

## Using the Validator


The Validator's jar runs in both [Java](https://www.java.com/) 8 or 11 enviroments. A usage message will be printed if the stationxml-validator is run with no arguments are supplied:

java -jar stationxml-validator-1.7.0.jar
Expand Down
3 changes: 2 additions & 1 deletion docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ DICTIONARY: External reference, such as the units name list
| | **`Channel Time Errors`** ||||
| 310 | Channel:startDate must be included and must occur before Channel:endDate if included.<details>Channel:startDate must be **INCLUDED AND** < Channel:endDate **IF INCLUDED**</details> |Error||[F1_310](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_310.xml), [F2_310](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F2_310.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml)|
| 320 | If Channel:Code[2]==(H &#124; L &#124; M &#124; N) THEN Channel:Azimuth and Channel:Dip must be included. |Error|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)| [F1_320](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_320.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml)|
| 321 |If Channel:Code[2] == (H &#124; L &#124; M &#124; N) then Stage[1]:InputUnit must equal *m/s* AND Stage[Last]:OutputUnits must equal count*|WARNING|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)| [F1_321](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_320.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml)|
| 321 |If Channel:Code[2] == (H &#124; L &#124; M &#124; N) then Stage[1]:InputUnit must equal *m/s* AND Stage[Last]:OutputUnits must equal count*|WARNING|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)| [F1_321](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_321.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml)|
||||||
| | **`Channel Orientation Errors`** ||||
| 330 |Channel:SampleRate must be assigned a float that inclusively correspounds to Channel:Code[1], which is outlined by the Band Code dictionary|WARNING|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)| [F1_321](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_330.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml)|
| 332 |If Channel:Code[LAST]==N then Channel:Azimuth must be assigned (>=355.0 or <=5.0) or (>=175.0 and <=185.0) and Channel:Dip must be assigned (>=-5 AND <=5.0). |Warning|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)|[F1_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_332.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml), [P1_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P1_332.xml), [P2_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P2_332.xml), [P3_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P3_332.xml), [P4_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P4_332.xml)|
| 333 |If Channel:Code[LAST]==E then Channel:Azimuth must be assigned (>=85.0 and <=95.0) or (>=265.0 and <=275.0) and Channel:Dip must be ASSIGNED (>=-5.0 and <=5.0). |Warning|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)|[F1_333](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_333.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml), [P1_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P1_332.xml), [P2_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P2_332.xml), [P3_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P3_332.xml), [P4_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P4_332.xml)|
| 334 |If Channel:Code[LAST]==Z then Channel:Azimuth must be assigned (>=355.0 or <=5.0) and Channel:Dip must be assigned (>=-85.0 and <=-90.0) or (>=85.0 and <=90.0). |Warning|[C1](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel), [C2](https://github.com/iris-edu/StationXML-Validator/wiki/Restrictions#channel)|[F1_334](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/F1_334.xml)|[PASS](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/Validator_Pass.xml), [P1_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P1_332.xml), [P2_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P2_332.xml), [P3_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P3_332.xml), [P4_332](https://github.com/iris-edu/StationXML-Validator/blob/master/src/test/resources/P4_332.xml)|
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/edu/iris/dmc/station/RuleEngineRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import edu.iris.dmc.fdsn.station.model.Response;
import edu.iris.dmc.fdsn.station.model.Station;
import edu.iris.dmc.station.conditions.AzimuthDipCondition;
import edu.iris.dmc.station.conditions.BandCodeCondition;
import edu.iris.dmc.station.conditions.CalibrationUnitCondition;
import edu.iris.dmc.station.conditions.CodeCondition;
import edu.iris.dmc.station.conditions.Condition;
Expand Down Expand Up @@ -186,6 +187,12 @@ private void defaultChannelRules(Set<Integer> set) {
new Restriction[] { new ChannelCodeRestriction(), new ChannelTypeRestriction() }),
Channel.class);
}
if (!set.contains(330)) {
add(330, new BandCodeCondition(true,
"Channel:SampleRate must be assigned a float that inclusively correspounds to Channel:Code[1], which is outlined by the Band Code dictionary",
new Restriction[] { new ChannelCodeRestriction(), new ChannelTypeRestriction() }),
Channel.class);
}
if (!set.contains(332)) {
add(332, new OrientationCondition(true,
"If Channel:Code[LAST]==N then Channel:Azimuth must be assigned (>=355.0 or <=5.0) or (>=175.0 and <=185.0) and Channel:Dip must be assigned (>=-5 AND <=5.0).",
Expand Down
180 changes: 180 additions & 0 deletions src/main/java/edu/iris/dmc/station/conditions/BandCodeCondition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
package edu.iris.dmc.station.conditions;

import edu.iris.dmc.fdsn.station.model.Channel;
import edu.iris.dmc.fdsn.station.model.Network;
import edu.iris.dmc.fdsn.station.model.ResponseStage;
import edu.iris.dmc.fdsn.station.model.SampleRate;
import edu.iris.dmc.fdsn.station.model.Station;
import edu.iris.dmc.station.exceptions.StationxmlException;
import edu.iris.dmc.station.restrictions.Restriction;
import edu.iris.dmc.station.rules.Message;
import edu.iris.dmc.station.rules.NestedMessage;
import edu.iris.dmc.station.rules.Result;

public class BandCodeCondition extends AbstractCondition {
private Restriction[] restrictions;

public BandCodeCondition(boolean required, String description, Restriction[] restrictions) {
super(required, description);
this.restrictions = restrictions;
}

@Override
public Message evaluate(Network network) {
throw new IllegalArgumentException("Not supported!");
}

@Override
public Message evaluate(Station station) {
throw new IllegalArgumentException("Not supported!");
}

@Override
public Message evaluate(Channel channel) {
NestedMessage nestedMessage = new NestedMessage();
boolean returnmessage = false;
String inputUnit ="";
String code = channel.getCode();
try {
if(channel.getResponse().getStage().size()==0) {
throw new StationxmlException("Response is missing from input StationXML");
}
for (Restriction r : this.restrictions)
if (r.qualifies(channel)) {
return Result.success();
}

Double samplerate = channel.getSampleRate().getValue();
String bandcode = Character.toString(code.charAt(0));
bandcode=bandcode.toUpperCase();
switch (bandcode){
case "F":
if(samplerate < 1000 || samplerate >= 5000) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 1000 and < 5000"));
returnmessage = true;
break;
}
break;
case "G":
if(samplerate < 1000 || samplerate >= 5000) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 1000 and < 5000"));
returnmessage = true;
break;
}
break;
case "D":
if(samplerate < 250 || samplerate >= 1000) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 250 and < 1000"));
returnmessage = true;
break;
}
break;
case "C":
if(samplerate < 250 || samplerate >= 1000) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 250 and < 1000"));
returnmessage = true;
break;
}
break;
case "E":
if(samplerate < 80 || samplerate >= 250) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 80 and < 250"));
returnmessage = true;
break;
}
break;
case "H":
if(samplerate < 80 || samplerate >= 250) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 80 and < 250"));
returnmessage = true;
break;
}
break;
case "S":
if(samplerate < 10.0 || samplerate >= 80.0) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 10 and < 80"));
returnmessage = true;
break;
}
break;
case "B":
if(samplerate < 10.0 || samplerate >= 80.0) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 10 and < 80"));
returnmessage = true;
break;
}
break;
case "M":
if(samplerate < 1 || samplerate >= 10) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 1 and < 10"));
returnmessage = true;
break;
}
break;
case "L":
if(samplerate < 0.1 || samplerate >= 10) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.1 and < 10"));
returnmessage = true;
break;
}
break;
case "V":
if(samplerate < 0.01 || samplerate >= 1) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.01 and < 1"));
returnmessage = true;
break;
}
break;
case "U":
if(samplerate < 0.001 || samplerate >= 0.1) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.001 and < 0.1"));
returnmessage = true;
break;
}
break;
case "R":
if(samplerate < 0.0001 || samplerate >= 0.001) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.0001 and < 0.001"));
returnmessage = true;
break;
}
break;
case "P":
if(samplerate < 0.00001 || samplerate >= 0.0001) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.00001 and < 0.0001"));
returnmessage = true;
break;
}
break;
case "T":
if(samplerate < 0.000001 || samplerate >= 0.00001) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned between >= 0.000001 and < 0.00001"));
returnmessage = true;
break;
}
break;
case "Q":
if(samplerate >= 0.000001) {
nestedMessage.add(Result.warning("Frequency Band " + bandcode +" must have a sample rate assigned < 0.000001"));
returnmessage = true;
break;
}
break;
default:
break;

}
}
catch(Exception e) {

}
if(returnmessage==true) {
return nestedMessage;
}else {
return Result.success();
}
}

}


Loading