BdsApi  3.0.12
This is the Blacknest BDS API.
BdsLib.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BdsLib.h Data File Access
3  * T.Barnaby, BEAM Ltd, 2008-12-03
4  *******************************************************************************
5  */
9 #ifndef BdsLib_H
10 #define BdsLib_H
11 
12 #include <BdsD.h>
13 #include <BdsC.h>
14 #include <BString.h>
15 
16 namespace Bds {
17 
18 const int NetworkNameLen = 3;
19 const int StationNameLen = 5;
20 const int ChannelTypeLen = 3;
21 const int ChannelAuxLen = 2;
22 const int SourceLen = 16;
23 
25 class ResponseObj : public Response {
26 public:
27  ResponseObj(const Response& response);
28  ~ResponseObj();
29 
31  void setString(BString str);
32 };
33 
35 class DataError {
36 public:
37  DataError();
38  DataError(int errorNumber, BString title, BString filename, BTimeStamp startTime, BTimeStamp endTime, DataInfo& dataInfo, BUInt channel, BString description, BString user = "");
39  DataError& set(int errorNumber, BString title, BString importFilename, BTimeStamp startTime, BTimeStamp endTime, DataInfo& dataInfo, BUInt channel, BString description, BString user = "");
40  void mergeDataInfo(const DataInfo& dataInfo, BUInt channel);
41 
42  int getErrorNumber() const;
43  BString getTitle() const;
44 
47  BString getString() const;
48 
49  int num() const;
50  const char* str() const;
51 
52  operator int() const;
53 
54 public:
66 };
67 
68 
72 
73 // Bds Channel name manipulations
74 void bdsChannelGetTypeAux(BString name, BString& type, BString& aux);
76 
77 // Bds Data Meta data manipulations
79 BError bdsDataInfoFromInfo(BDictString info, DataInfo& dataInfo, Bool append = 0);
80 BError bdsInfoFromDataInfo(const DataInfo& dataInfo, BDictString& info);
82 BError bdsDataInfoMergeFlatten(DataInfo& dataInfo, const DataInfo& dataInfoAdd);
84 
85 BError bdsMetadataImportFix(ChannelInfos& channelInfos, Bool stageRenumber);
86 BError bdsMetadataExportFix(ChannelInfos& channelInfos, Bool singleResponse, Bool stageRenumber, Bool changeUnits, Bool stageGains, Bool decimation, Bool toDisplacement, Bool toNm);
87 
89 BString bdsDataChannelInfo(const DataChannel& dataChannel);
90 BString bdsDataChannelRef(const DataChannel& dataChannel);
91 BString bdsDataChannelRef(const ChannelInfo& channelInfo);
92 BError bdsDataChannelOverallResponse(const ChannelInfo& channelInfo, Response& response);
93 BString bdsSelectionChannelInfo(const Selection& selection, BUInt channel);
94 BString bdsFileNameExpand(BString fileName, ChannelInfo& channelInfo);
95 BString bdsFileNameExpand(BString fileName, ChannelInfos& channelInfos);
97 
98 // BDS Metadata higher level functionality
99 void bdsSpecialChannelsSet(const BList<SpecialChannel> specialChannels);
101 Bool bdsSpecialChannelIgnore(BString network, BString station, BString channel);
102 char seedChannelInstrumentCode(BString dataType);
104 BStringList bdsDataTypes();
105 BStringList bdsUnits();
107 
108 // Calculations
109 double bdsPoleZeroGain(const PoleZero& poleZero, double frequency);
110 void bdsPoleZeroGainPhase(const PoleZero& poleZero, double frequency, double& gain, double& phase);
111 void bdsPoleZeroToFap(const PoleZero& poleZero, BUInt nPoints, double calibrationFrequency, double sampleFrequency, BArray<Fap>& fap);
112 
113 // Bds Debug functions
114 void bdsDumpSelection(Selection sel);
116 void bdsDumpDataInfo(DataInfo dataInfo, int includeInfo = 0);
117 void bdsDumpChannelInfos(const ChannelInfos& channelInfos);
118 void bdsDumpData(const DataBlock& dataBlock, int nSamples = 0);
119 void bdsDumpPoleZeros(PoleZero poleZeros);
120 void bdsDumpLocation(Location location);
121 
122 }
123 #endif
BUInt32 BUInt
bool Bool
int32_t BInt32
BOAP data class definitions for: Bds.
This is the AdminAccess Access API interface.
Definition: BdsC.h:183
This class provides information on a channel.
Definition: BdsD.h:534
This class provides metadata information on a set of channels.
Definition: BdsD.h:556
This is the Data Access API interface.
Definition: BdsC.h:26
This is the DataAdd Access API interface.
Definition: BdsC.h:103
This class provides the actual seismic data values contained within a single data block.
Definition: BdsD.h:699
This class defines information on a single channels set of data stored in a file.
Definition: BdsD.h:597
This stores a data error. It includes and error number and a string as well as information on what se...
Definition: BdsLib.h:35
BString osource
The data Source.
Definition: BdsLib.h:64
BString getTitle() const
Get the title.
Definition: BdsLib.cpp:101
BString odescription
The description.
Definition: BdsLib.h:57
int num() const
Get The error number.
Definition: BdsLib.cpp:160
BString ofilename
The import filename;.
Definition: BdsLib.h:58
BTimeStamp oendTime
The end Time.
Definition: BdsLib.h:60
BError setStringUser(BString str, BString user)
Set from string given by user on command line.
Definition: BdsLib.cpp:143
DataError()
Definition: BdsLib.cpp:39
BString ochannel
The channel name.
Definition: BdsLib.h:63
BString getString() const
Get error message.
Definition: BdsLib.cpp:154
DataError & set(int errorNumber, BString title, BString importFilename, BTimeStamp startTime, BTimeStamp endTime, DataInfo &dataInfo, BUInt channel, BString description, BString user="")
Definition: BdsLib.cpp:47
BError setString(BString str)
Set from string.
Definition: BdsLib.cpp:109
BString onetwork
The network Name.
Definition: BdsLib.h:61
int getErrorNumber() const
Get The error number.
Definition: BdsLib.cpp:97
BString ouser
The user.
Definition: BdsLib.h:65
BInt32 oerrorNumber
Error number.
Definition: BdsLib.h:55
void mergeDataInfo(const DataInfo &dataInfo, BUInt channel)
Definition: BdsLib.cpp:65
BString otitle
The title.
Definition: BdsLib.h:56
BString ostation
The station/array name.
Definition: BdsLib.h:62
const char * str() const
Return a char* string.
Definition: BdsLib.cpp:164
BTimeStamp ostartTime
The start Time.
Definition: BdsLib.h:59
This class defines information on a set of data.
Definition: BdsD.h:632
This class defines the physical location of a Station.
Definition: BdsD.h:203
This class defines a Pole/Zero Response.
Definition: BdsD.h:229
Response object adding string conversion.
Definition: BdsLib.h:25
ResponseObj(const Response &response)
Definition: BdsLib.cpp:14
BString getString()
Definition: BdsLib.cpp:20
~ResponseObj()
Definition: BdsLib.cpp:17
void setString(BString str)
Definition: BdsLib.cpp:35
This class defines a seismic Response characteristic.
Definition: BdsD.h:307
This class defines the set of metadata or siesmic data selected when getSelectionInfo() is use.
Definition: BdsD.h:474
This class defines a generic metadata or seismic data selection.
Definition: BdsD.h:507
This class defines a seismic station.
Definition: BdsD.h:187
Definition: BdsC.cc:8
BString bdsUnitsConvert(BString units)
Tidy up units name to standard SI units format.
Definition: BdsLib.cpp:585
BString bdsDataChannelInfo(const DataChannel &dataChannel)
Returns a string representation of a DataChannel object.
Definition: BdsLib.cpp:1036
BString bdsUnitCase(BString unit)
Converts character case of units.
Definition: BdsLib.cpp:1411
void bdsPoleZeroGainPhase(const PoleZero &poleZero, double frequency, double &gain, double &phase)
Calculates the overall gain and phase of the given PoleZero transfer function.
Definition: BdsLib.cpp:1096
Bool bdsSpecialChannelIgnore(BString network, BString station, BString channel)
Check if channel should be ignored.
Definition: BdsLib.cpp:1314
const int ChannelAuxLen
Maximum Channel Aux length.
Definition: BdsLib.h:21
BError bdsDataInfoFlatten(DataInfo &dataInfo)
Flattens a DataInfo to 1 segement per channel for use in dataOpen() calls.
Definition: BdsLib.cpp:494
BError bdsLibInit(DataAccess &bds)
Initialise the bdsLib with settings from the BdsServer.
Definition: BdsLib.cpp:169
const int SourceLen
Maximum Source length.
Definition: BdsLib.h:22
BString bdsChannelGetName(BString type, BString aux)
Create a full channel name from a channels type and aux fields.
Definition: BdsLib.cpp:215
BString seedChannelDataType(BString channel)
Returns dataType from channel name based on SEED channel name convention.
Definition: BdsLib.cpp:1379
const int StationNameLen
Maximum Station name length.
Definition: BdsLib.h:19
BStringList bdsUnits()
Returns all known SI units.
Definition: BdsLib.cpp:1405
BString bdsDataChannelRef(const DataChannel &dataChannel)
Returns the string reference name of a DataChannel object.
Definition: BdsLib.cpp:1041
const int NetworkNameLen
Maximum Network name length.
Definition: BdsLib.h:18
BStringList bdsDataTypes()
Returns all known data types.
Definition: BdsLib.cpp:1392
BError bdsDataChannelOverallResponse(const ChannelInfo &channelInfo, Response &response)
Returns the overal response from the list of responses in a ChannelInfo.
Definition: BdsLib.cpp:1049
void bdsSpecialChannelsSet(const BList< SpecialChannel > specialChannels)
Set the special channels list.
Definition: BdsLib.cpp:1298
BString bdsSelectionChannelInfo(const Selection &selection, BUInt channel)
Returns a string describing the name and time period of a selection channel.
Definition: BdsLib.cpp:1072
void bdsDumpDataInfo(DataInfo dataInfo, int includeInfo)
Debug print out a DataInfo object.
Definition: BdsLib.cpp:925
BError bdsDataInfoMergeFlatten(DataInfo &dataInfo, const DataInfo &dataInfoAdd)
Merges a DataInfo into another flattening the segments to 1 for use in dataOpen() calls.
Definition: BdsLib.cpp:515
BString bdsFileNameExpand(BString fileName, ChannelInfo &channelInfo)
Default filename from a ChannelInfo.
Definition: BdsLib.cpp:1154
BString bdsStationAlias(Station station)
Returns the station alias if set else its name.
Definition: BdsLib.cpp:856
BError bdsMetadataImportFix(ChannelInfos &channelInfos, Bool stageRenumber)
Fix up ChannelInfos from import. Mainly making sure response stages and their units are correct.
Definition: BdsLib.cpp:615
void bdsDumpLocation(Location location)
Debug printout location.
Definition: BdsLib.cpp:1032
void bdsDumpPoleZeros(PoleZero poleZeros)
Debug print out a PoleZeros object.
Definition: BdsLib.cpp:199
void bdsPoleZeroToFap(const PoleZero &poleZero, BUInt nPoints, double calibrationFrequency, double sampleFrequency, BArray< Fap > &fap)
Convert PoleZero to FAP.
Definition: BdsLib.cpp:1116
BError bdsDataInfoFromInfo(BDictString info, DataInfo &dataInfo, Bool append)
Convert info to DataInfo.
Definition: BdsLib.cpp:245
const int ChannelTypeLen
Maximum Channel type name length.
Definition: BdsLib.h:20
void bdsDumpSelectionInfo(SelectionInfo sel)
Debug print out a SelectionInfo object.
Definition: BdsLib.cpp:886
void bdsChannelGetTypeAux(BString name, BString &type, BString &aux)
Get the channel type and aux fields from a generic channel name.
Definition: BdsLib.cpp:208
BError bdsMetadataExportFix(ChannelInfos &channelInfos, Bool singleResponse, Bool stageRenumber, Bool changeUnits, Bool stageGains, Bool decimation, Bool toDisplacement, Bool toNm)
Fix up ChannelInfos for export. Mainly making sure response stages and their units are correct.
Definition: BdsLib.cpp:687
BList< SpecialChannel > bdsSpecialChannels()
Return list of special channels.
Definition: BdsLib.cpp:1302
void bdsDumpSelection(Selection sel)
Debug print out a Selection object.
Definition: BdsLib.cpp:863
BError bdsDataInfoSetTimeRange(DataInfo &dataInfo)
Restricts the time tange of all of the DataInfo's channels to match the DataInfo's startTime/endTime ...
Definition: BdsLib.cpp:223
void bdsDumpChannelInfos(const ChannelInfos &channelInfos)
Debug print out a ChannelInfos object.
Definition: BdsLib.cpp:974
BError bdsInfoFromDataInfo(const DataInfo &dataInfo, BDictString &info)
Converts a DataInfo object into a BDictString list of named strings.
Definition: BdsLib.cpp:367
void bdsDumpData(const DataBlock &dataBlock, int nSamples)
Debug print out a DataBlock object.
Definition: BdsLib.cpp:1008
char seedChannelInstrumentCode(BString dataType)
Returns SEED instrument code from dataType.
Definition: BdsLib.cpp:1366
double bdsPoleZeroGain(const PoleZero &poleZero, double frequency)
Calculates the overall gain of the given PoleZero transfer function.
Definition: BdsLib.cpp:1079