Documentation
¶
Overview ¶
Automatically generate stationxml bindings from the schema files.
Index ¶
- Constants
- Variables
- func Decode(version string, data []byte) ([]byte, error)
- func Decode10(data []byte) ([]byte, error)
- func Decode11(data []byte) ([]byte, error)
- func Decode12(data []byte) ([]byte, error)
- func Encode10(r Root) ([]byte, error)
- func Encode11(r Root) ([]byte, error)
- func Encode12(r Root) ([]byte, error)
- func ToSiteSurvey(survey string) string
- type ApproximationBound
- type Channel
- type CoefficientDenominator
- type CoefficientNumerator
- type CoefficientsType
- type DecimationType
- type Decoder10
- type Decoder11
- type Decoder12
- type Encoder10
- func (e Encoder10) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
- func (e Encoder10) MarshalRoot(root Root) ([]byte, error)
- func (e Encoder10) Network(root Root, external External) stationxml.NetworkType
- func (e Encoder10) Response(response *resp.ResponseType) *stationxml.ResponseType
- func (e Encoder10) Station(root Root, external External, network Network, station Station) stationxml.StationType
- type Encoder11
- func (e Encoder11) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
- func (e Encoder11) MarshalRoot(root Root) ([]byte, error)
- func (e Encoder11) Network(root Root, external External) stationxml.NetworkType
- func (e Encoder11) Response(response *resp.ResponseType) *stationxml.ResponseType
- func (e Encoder11) Station(root Root, external External, network Network, station Station) stationxml.StationType
- type Encoder12
- func (e Encoder12) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
- func (e Encoder12) MarshalRoot(root Root) ([]byte, error)
- func (e Encoder12) Network(root Root, external External) stationxml.NetworkType
- func (e Encoder12) Response(response *resp.ResponseType) *stationxml.ResponseType
- func (e Encoder12) Station(root Root, external External, network Network, station Station) stationxml.StationType
- type Equipment
- type External
- type FirType
- type Float
- type InstrumentPolynomial
- type InstrumentSensitivity
- type Network
- type NumeratorCoefficient
- type PoleZero
- type PolesZerosType
- type PolynomialCoefficient
- type PolynomialType
- type Response
- func (r *Response) Coeffs() []PolynomialCoefficient
- func (r *Response) Config(opts ...ResponseOpt)
- func (r *Response) Derived(data []byte) (*ResponseType, error)
- func (r *Response) Marshal() ([]byte, error)
- func (r *Response) Normalise() error
- func (r *Response) Polynomial() *PolynomialType
- func (r *Response) ResponseType() (*ResponseType, error)
- func (r *Response) Scale() float64
- func (r *Response) SetCalibration(scale, bias, absolute float64)
- func (r *Response) SetDatalogger(data []byte) error
- func (r *Response) SetFrequency(frequency float64)
- func (r *Response) SetGain(scale, bias, absolute float64)
- func (r *Response) SetPreamp(preamp float64)
- func (r *Response) SetPrefix(prefix string)
- func (r *Response) SetSensor(data []byte) error
- func (r *Response) SetSerial(serial string)
- func (r *Response) SetTelemetry(gain float64)
- type ResponseOpt
- func Calibration(factor, bias, absolute float64) ResponseOpt
- func Frequency(frequency float64) ResponseOpt
- func Gain(factor, bias, absolute float64) ResponseOpt
- func Preamp(preamp float64) ResponseOpt
- func Prefix(prefix string) ResponseOpt
- func Serial(serial string) ResponseOpt
- func Telemetry(gain float64) ResponseOpt
- type ResponseStageType
- type ResponseType
- type Root
- func (r Root) ExternalCode() string
- func (r Root) MarshalVersion(version string) ([]byte, error)
- func (r Root) NetworkCode() string
- func (r Root) Single(code string) (Root, bool)
- func (r Root) StationCode() string
- func (r Root) Write(wr io.Writer, version string) error
- func (r Root) WriteFile(path string, version string) error
- type StageGain
- type Station
- type Stream
- type Units
Constants ¶
const LaplaceRadiansSecondPzTransferFunction = "LAPLACE (RADIANS/SECOND)"
Variables ¶
var ErrInvalidResponse = errors.New("attempt to correct the wrong type of response, biases require a polynomial response")
Functions ¶
func ToSiteSurvey ¶
ToSiteSurey returns the survey notes fro a given survey method.
Types ¶
type ApproximationBound ¶
type ApproximationBound struct {
Value float64 `xml:",chardata"`
}
type Channel ¶
type Channel struct { LocationCode string Latitude float64 Longitude float64 Elevation float64 Survey string Datum string Streams []Stream }
Channel forms the main part of a set of StationXML Channel elements
type CoefficientDenominator ¶
type CoefficientNumerator ¶
type CoefficientsType ¶
type CoefficientsType struct { ResourceId string `xml:"resourceId,attr,omitempty"` Name string `xml:"name,attr,omitempty"` Description string `xml:"description,attr,omitempty"` InputUnits Units `xml:"InputUnits"` OutputUnits Units `xml:"OutputUnits"` CfTransferFunctionType string `xml:"CfTransferFunctionType"` Numerators []CoefficientNumerator `xml:"Numerator,omitempty"` Denominators []CoefficientDenominator `xml:"Denominator,omitempty"` }
type DecimationType ¶
type Encoder10 ¶
type Encoder10 struct{}
func (Encoder10) Channel ¶
func (e Encoder10) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
func (Encoder10) Network ¶
func (e Encoder10) Network(root Root, external External) stationxml.NetworkType
func (Encoder10) Response ¶
func (e Encoder10) Response(response *resp.ResponseType) *stationxml.ResponseType
func (Encoder10) Station ¶
func (e Encoder10) Station(root Root, external External, network Network, station Station) stationxml.StationType
type Encoder11 ¶
type Encoder11 struct{}
func (Encoder11) Channel ¶
func (e Encoder11) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
func (Encoder11) Network ¶
func (e Encoder11) Network(root Root, external External) stationxml.NetworkType
func (Encoder11) Response ¶
func (e Encoder11) Response(response *resp.ResponseType) *stationxml.ResponseType
func (Encoder11) Station ¶
func (e Encoder11) Station(root Root, external External, network Network, station Station) stationxml.StationType
type Encoder12 ¶
type Encoder12 struct{}
func (Encoder12) Channel ¶
func (e Encoder12) Channel(root Root, network Network, channel Channel) []stationxml.ChannelType
func (Encoder12) Network ¶
func (e Encoder12) Network(root Root, external External) stationxml.NetworkType
func (Encoder12) Response ¶
func (e Encoder12) Response(response *resp.ResponseType) *stationxml.ResponseType
func (Encoder12) Station ¶
func (e Encoder12) Station(root Root, external External, network Network, station Station) stationxml.StationType
type Equipment ¶
type Equipment struct { Type string Description string Manufacturer string Model string SerialNumber string InstallationDate time.Time RemovalDate time.Time Response string }
Equipment describes a StationXML Equipment element
type External ¶
type External struct { Code string Description string Restricted bool StartDate time.Time EndDate time.Time Networks []Network }
External maps between an External Network and individal Networks.
type FirType ¶
type FirType struct { ResourceId string `xml:"resourceId,attr"` Name string `xml:"name,attr,omitempty"` Description string `xml:"description,attr,omitempty"` InputUnits Units `xml:"InputUnits"` OutputUnits Units `xml:"OutputUnits"` Symmetry string `xml:"Symmetry"` NumeratorCoefficients []NumeratorCoefficient `xml:"NumeratorCoefficient"` }
type InstrumentPolynomial ¶
type InstrumentPolynomial struct { ResourceId string `xml:"resourceId,attr,omitempty"` Name string `xml:"name,attr"` Description string `xml:"description,attr,omitempty"` InputUnits Units `xml:"InputUnits"` OutputUnits Units `xml:"OutputUnits"` ApproximationType string `xml:"ApproximationType"` FrequencyLowerBound float64 `xml:"FrequencyLowerBound"` FrequencyUpperBound float64 `xml:"FrequencyUpperBound"` ApproximationLowerBound ApproximationBound `xml:"ApproximationLowerBound"` ApproximationUpperBound ApproximationBound `xml:"ApproximationUpperBound"` MaximumError float64 `xml:"MaximumError"` Coefficients []PolynomialCoefficient `xml:"Coefficient,omitempty"` }
type InstrumentSensitivity ¶
type NumeratorCoefficient ¶
type PolesZerosType ¶
type PolesZerosType struct { ResourceId string `xml:"resourceId,attr"` Name string `xml:"name,attr,omitempty"` Description string `xml:"description,attr,omitempty"` InputUnits Units `xml:"InputUnits"` OutputUnits Units `xml:"OutputUnits"` PzTransferFunctionType string `xml:"PzTransferFunctionType"` NormalizationFactor float64 `xml:"NormalizationFactor"` NormalizationFrequency float64 `xml:"NormalizationFrequency"` Zeros []PoleZero `xml:"Zero"` Poles []PoleZero `xml:"Pole"` }
func (PolesZerosType) Gain ¶
func (pz PolesZerosType) Gain(freq float64) float64
Gain ccalculates the poles and zeros response gain at a given frequency
type PolynomialCoefficient ¶
type PolynomialType ¶
type PolynomialType struct { ResourceId string `xml:"resourceId,attr,omitempty"` Name string `xml:"name,attr,omitempty"` Description string `xml:"description,attr,omitempty"` InputUnits Units `xml:"InputUnits"` OutputUnits Units `xml:"OutputUnits"` ApproximationType string `xml:"ApproximationType"` FrequencyLowerBound float64 `xml:"FrequencyLowerBound"` FrequencyUpperBound float64 `xml:"FrequencyUpperBound"` ApproximationLowerBound ApproximationBound `xml:"ApproximationLowerBound"` ApproximationUpperBound ApproximationBound `xml:"ApproximationUpperBound"` MaximumError float64 `xml:"MaximumError"` Coefficients []PolynomialCoefficient `xml:"Coefficient,omitempty"` }
func (PolynomialType) Value ¶
func (p PolynomialType) Value(input float64) float64
type Response ¶
type Response struct { Prefix string Serial string Frequency float64 ScaleFactor float64 ScaleBias float64 ScaleAbsolute float64 GainFactor float64 GainBias float64 GainAbsolute float64 Telemetry float64 Preamp float64 // contains filtered or unexported fields }
Response is used for building an instrument response based on sensor and datalogger pairs. It makes no assumption about the StationXML version, ideally it should encompass all required elements. The conversion from a bas Response to a particular version is done via encoding interfaces.
func NewResponse ¶
func NewResponse(opts ...ResponseOpt) *Response
NewResponse builds a Response with the given options.
func (*Response) Coeffs ¶
func (r *Response) Coeffs() []PolynomialCoefficient
Coeffs returns a slice of PolynomialCoeffiencent values present in the Response.
func (*Response) Config ¶
func (r *Response) Config(opts ...ResponseOpt)
Config can be used to set extra Response options.
func (*Response) Derived ¶
func (r *Response) Derived(data []byte) (*ResponseType, error)
Derived returns a ResponseType when there is only a single set of derived Response stages.
func (*Response) Marshal ¶
Marshal generates an XML encoded version of the Response as a ResponseType.
func (*Response) Polynomial ¶
func (r *Response) Polynomial() *PolynomialType
Polynomial finds the PolynomialType in the Response if one is present.
func (*Response) ResponseType ¶
func (r *Response) ResponseType() (*ResponseType, error)
ResponseType builds a combined ResponseType from a Response.
func (*Response) SetCalibration ¶
SetCalibration is used to set a initial sensor reference gain, this overrides the default values.
func (*Response) SetDatalogger ¶
SetDatalogger takes an XML encoded ResponseType that represents a Datalogger and adds it to the Response.
func (*Response) SetFrequency ¶
SetFrequency is used to set the overall reference frequency for the Response.
func (*Response) SetGain ¶
SetGain is used to adjusts the installed sensor gains, this is in addition to the default values.
func (*Response) SetPreamp ¶
SetPreamp is used to adjusts the datalogger gains, this is in addition to the default values.
func (*Response) SetSensor ¶
SetSensor takes an XML encoded ResponseType that represents a Sensor and adds it to the Response.
func (*Response) SetTelemetry ¶
SetTelemetry is used to adjusts the datalogger gains, this is in addition to the default values.
type ResponseOpt ¶
type ResponseOpt func(*Response)
func Calibration ¶
func Calibration(factor, bias, absolute float64) ResponseOpt
Calibration is used to set a initial sensor reference gain, this overrides the default values.
func Frequency ¶
func Frequency(frequency float64) ResponseOpt
Frequency is used to set the overall reference frequency for the Response.
func Gain ¶
func Gain(factor, bias, absolute float64) ResponseOpt
Gain is used to adjusts the installed sensor gains, this is in addition to the default values.
func Preamp ¶
func Preamp(preamp float64) ResponseOpt
Preamp is used to adjusts the datalogger gains, this is in addition to the default values.
func Prefix ¶
func Prefix(prefix string) ResponseOpt
Prefix sets the label used to prefix Response element names.
func Serial ¶
func Serial(serial string) ResponseOpt
Serial sets the label used to prefix Response equipment labels.
func Telemetry ¶
func Telemetry(gain float64) ResponseOpt
Telemetry is used to adjusts the sensor and datalogger connection gain, this is in addition to the default values.
type ResponseStageType ¶
type ResponseStageType struct { Number int `xml:"number,attr"` Coefficients *CoefficientsType `xml:"Coefficients,omitempty"` Decimation *DecimationType `xml:"Decimation,omitempty"` FIR *FirType `xml:"FIR,omitempty"` PolesZeros *PolesZerosType `xml:"PolesZeros,omitempty"` Polynomial *PolynomialType `xml:"Polynomial,omitempty"` StageGain *StageGain `xml:"StageGain,omitempty"` }
func (*ResponseStageType) Clone ¶
func (r *ResponseStageType) Clone() (ResponseStageType, error)
clone two responses to avoid shared backing arrays
type ResponseType ¶
type ResponseType struct { XMLName xml.Name `xml:"Response"` ResourceId string `xml:"resourceId,attr,omitempty"` InstrumentSensitivity *InstrumentSensitivity `xml:"InstrumentSensitivity,omitempty"` InstrumentPolynomial *InstrumentPolynomial `xml:"InstrumentPolynomial,omitempty"` Stages []ResponseStageType `xml:"Stage,omitempty"` // contains filtered or unexported fields }
ResponseType is a struct that mimics the StationXML ResponseType element, but is not constrained to a particular version.
func NewResponseType ¶
func NewResponseType(data []byte) (*ResponseType, error)
func (ResponseType) Marshal ¶
func (r ResponseType) Marshal() ([]byte, error)
func (*ResponseType) PolynomialCoefficients ¶
func (r *ResponseType) PolynomialCoefficients() []PolynomialCoefficient
func (*ResponseType) PolynomialType ¶
func (r *ResponseType) PolynomialType() *PolynomialType
func (*ResponseType) Scale ¶
func (r *ResponseType) Scale() float64
func (*ResponseType) Unmarshal ¶
func (r *ResponseType) Unmarshal(data []byte) error
type Root ¶
Root describes the standard StationXML layout which can be used as the barebones for building version specific encoders.
func (Root) ExternalCode ¶
ExternalCode returns the network code of the first External entry in the Root structure, this is aimed at building single entry file names.
func (Root) MarshalVersion ¶
Encode encodes the Root struct using the given Encoder.
func (Root) NetworkCode ¶
NetworkCode returns the network code of the first Network entry in the Root structure, this is aimed at building single entry file names.
func (Root) StationCode ¶
StationCode returns the station code of the first Station entry in the Root structure, this is aimed at building single entry file names.
type Station ¶
type Station struct { Code string Name string Description string Latitude float64 Longitude float64 Elevation float64 Survey string Datum string StartDate time.Time EndDate time.Time CreationDate time.Time TerminationDate time.Time Channels []Channel }
Station forms the main part of a StationXML Station element.
type Stream ¶
type Stream struct { Code string SamplingRate float64 Triggered bool Types string Vertical float64 Azimuth float64 Dip float64 Datalogger Equipment Sensor Equipment StartDate time.Time EndDate time.Time Response *resp.ResponseType }
Stream forms the main part of an individual StationXML Channel element