(*********************************************************************** This file was generated automatically by the Mathematica front end. It contains Initialization cells from a Notebook file, which typically will have the same name as this file except ending in ".nb" instead of ".m". This file is intended to be loaded into the Mathematica kernel using the package loading commands Get or Needs. Doing so is equivalent to using the Evaluate Initialiation Cells menu command in the front end. DO NOT EDIT THIS FILE. This entire file is regenerated automatically each time the parent Notebook file is saved in the Mathematica front end. Any changes you make to this file will be overwritten. ***********************************************************************) (*:Name: LIGO`nds` *) (*:Author: Daniel Sigg, December 1999 *) (*:Summary: This package provides access to LIGO data through a MathLink interface to the Network data server. *) (*:Keywords: Network data server, LIGO *) (*:Sources: *) BeginPackage ["LIGO`nds`"]; LHO::usage= "The option value LHO is used to represente the site of the LIGO Hanford \ Observatory."; LLO::usage= "The option value LHO is used to represente the site of the LIGO Hanford \ Observatory."; Site::usage= "Site is an option which is used to specify the loaction of the data \ server. Supported values are LHO, LLO or a string describing the port number \ and server name in the format \"1234@daniel.ligo-wa.caltech.edu\""; $DefaultSite::usage= "$DefaultSite is used to specify the default location of the NDS data \ server."; ColumnFormat::usage= "ColumnFormat is an option representing a data format where each channel is \ stored as an individual data array."; RowFormat::usage= "RowFormat is an option representing a data format where the data is stored \ in n-tuples of channel points."; DataFormat::usage= "The option DataFormat specifies the format of the returned data array. \ Possible values are RowFormat or ColumnFormat. In row format the data is \ returned as a list of n-tuples representing the time, the value of the first \ channel, the value of the second channel, etc. In column format the data is \ returned as a list of channels data arrays. The first data array always \ describes the time."; DataRate::usage= "DataRate is an option to specify the sampling rate of the returned data \ array. The value is specified in units of Hz."; Heterodyne::usage= "The Heterodyne option is used to down-convert the data by the specified \ rate before it is returned. The value is specified in units of Hz. The \ returned data values will be complex."; ChannelName::usage= "ChannelName is an options used by NDSGetChannelInfo to return the channel \ name."; InterferometerId::usage= "InterferometerId is an options used by NDSGetChannelInfo to return the \ interferometer identification number."; DCU::usage= "DCU is an options used by NDSGetChannelInfo to return the DCU \ information."; NDSDataType::usage= "NDSDataType is an options used by NDSGetChannelInfo to return the native \ data type."; NDSClose::usage="NDSClose[] terminates the connection to the NDS server."; NDSGetChannel::usage= "NDSGetChannel[] obtains a list of all currently available channel names. \ The following option can be given: Site (default $DefaultSite) which \ specifies the location of the NDS server."; NDSGetChannelInfo::usage= "NDSGetChannelInfo[] obtains a list of all currently available channel \ names and the information assciated with them. Each channel is represented by \ a list with the following elements: {ChannelName->\"name\", \ DataRate\[Rule]rate,InterferometerId\[Rule]ifo, DCU\[Rule]id, NDSDataType\ \[Rule]dtype}. The data rate is specified in units of Hz; the interferometer \ number is either 0 for the 4k intereformeter or 1 for the 2k; the DCU id is \ the idendification number of data collection unit which collected the \ channel; and the data type is one of the following: 1 \[Dash] short integer \ (16 bit), 2 \[Dash] integer (32 bit), 3 \[Dash] long integer (64 bit), 4 \ \[Dash] single precision floating point number (32 bit), and 5 \[Dash] double \ precision floating point number (64 bit). The following option can be given: \ Site (default $DefauiltSite)which specifies the location of the NDS server."; NDSGetData::usage= "NDSGetData[\"channel\"], start, duratio] obtains data for a single channel \ from the network data server. NDSGetData[\"chn1\", \"chn2\", ...}, start, \ duration] obtains data for multiple channels from the network datya server. \ The following options can be given: DataRate (default 256) which specifies \ the sampling rate of the returned data, DataFormat (default ColumnFormat) \ which specifies the format of the returned data array, Heterodyne (default 0) \ which specifies the down-conversion frequency, and Site (default \ $DefaultSite) which specifies the location of the NDS server."; NDSGetTrend::usage= "NDSGetTrend[\"channel\", start, duratio] obtains trend data for a single \ channel from the network data server. NDSGetTrend[\"chn1\", \"chn2\", ...}, \ start, duration] obtains trend data for multiple channels from the network \ datya server. Each returned data point constist of an n-tuple consisting of \ the time, the mean value, the rms value, the maximum and the minimum. The \ returned data format is always in row format. The data rate has to be smaller \ or equal one Hertz. For rates faster than once a minute, the rate must be an \ integer fraction of one. For rate slower than once a minute the rate must be \ an integer fraction of 1/60. The following options can be given: DataRate \ (default 1)which specifies the sampling rate of the returned data, and Site \ (default $DefaultSite) which specifies the location of the NDS server."; NDSTrendEliminateInvalid::usage= "Eliminates invalid data points from a returned trend data array. Invalid \ data points are recognized by an N of zero." nds::nosite="Unsupported site name."; nds::optx="Unsupported option(s) `1` encountered."; nds::nochn="No channel names."; nds::time="Invalid time specification."; nds::rate="Invalid rate specification (must be a power of two)."; nds::fdown="Invalid heterodyn frequency."; nds::duration="Invalid time duration."; nds::server="NDS server not available."; nds::server2="Unable to request data from NDS server."; nds::server3="Server transmission error."; nds::chn="Invalid channel names specified."; nds::nomem="Unsufficient memory."; nds::pre="Unable to initialize preprocessor."; nds::unknown="Unexpected error."; Begin["`Private`"]; Attributes[LHO]={Protected}; Attributes[LLO]={Protected}; Attributes[Site]={Protected}; Attributes[ColumnFormat]={Protected}; Attributes[RowFormat]={Protected}; Attributes[DataFormat]={Protected}; Attributes[DataRate]={Protected}; Attributes[Heterodyne]={Protected}; Attributes[ChannelName]={Protected}; Attributes[InterferometerId]={Protected}; Attributes[DCU]={Protected}; Attributes[NDSDataType]={Protected}; NDSLocations= {LHO\[Rule]"9090@gold.ligo-wa.caltech.edu", LLO\[Rule]"9090@nashville.ligo-la.caltech.edu"}; CurrentLocation=""; NDSLink=0; $DefaultSite=LHO; IllegaleOptions[ command_Symbol, opts___ ] := Select[ Flatten[{opts}],!MemberQ[First /@ Options[command], First[#]]& ] CheckOptions[command_Symbol, options___]:= Module[{l}, l=IllegaleOptions[command,options]; If[Length[l]>0,Message[nds::optx, l];Abort[],0]] ChannelArg[channel_List/;VectorQ[channel,Head[#]===String&]]:= StringJoin[#<>"\t"&/@channel] EstablishLink[location_String]:= Module[{link}, If[location===CurrentLocation,NDSLink, NDSClose[]; link=Install[LinkConnect[location,LinkProtocol->"TCP"]]; If[Head[link]=!=LinkObject,Abort[]]; CurrentLocation= location; If[Head[NDSLink]==LinkObject,LinkClose[NDSLink]]; NDSLink=link]] EstablishLink[location_]:= Module[{loc}, loc = location/.NDSLocations; If[Head[loc]===String,EstablishLink[loc], Message[nds::nosite];Abort[]]] Real2Complex[l_List/;VectorQ[l,NumberQ]]:=Complex@@#&/@Partition[l,2] CheckForErrors1[l_]:= If[Head[l]===Integer, Switch[l,-1,Message[nds::nochn], -2, Message[nds::time], -3, Message[nds::rate], -4, Message[nds::fdown], -5, Message[nds::duration], -6, Message[nds::server], -7, Message[nds::chn], -8, Message[nds::nochn], -9, Message[nds::rate], -10, Message[nds::nomem], -11, Message[nds::pre], -12, Message[nds::server2], -13, Message[nds::server3], -99,Null, _, Message[nds::unknown] ];Abort[]] CheckForErrors2[l_]:= If[Head[l]===Integer, Switch[l,-1,Message[nds::nochn], -2, Message[nds::time], -3, Message[nds::rate], -4, Message[nds::duration], -5, Message[nds::server], -6, Message[nds::chn], -7, Message[nds::nochn], -8, Message[nds::nomem], -9, Message[nds::server2], -99,Null, _, Message[nds::unknown] ];Abort[],l] Options[NDSClose]={}; NDSClose[]:=Module[{}, If[Head[NDSLink]===LinkObject,LinkClose[NDSLink]]; NDSLink=0;CurrentLocation= "";] Options[NDSGetChannel]={Site\[RuleDelayed]$DefaultSite}; NDSGetChannel[opts___]:= Module[{site}, CheckOptions[NDSGetChannel, opts];site=Site/.{opts}/.Options[NDSGetChannel]; EstablishLink[site];Global`ndsgetchannels[]] Options[NDSGetChannelInfo]={Site\[RuleDelayed]$DefaultSite}; NDSGetChannelInfo[opts___]:= Module[{site, info}, CheckOptions[NDSGetChannelInfo, opts]; site=Site/.{opts}/.Options[NDSGetChannelInfo];EstablishLink[site]; info=Global`ndsgetchannelinfo[]; {ChannelName\[Rule]#\[LeftDoubleBracket]1\[RightDoubleBracket], DataRate\[Rule]#\[LeftDoubleBracket]2\[RightDoubleBracket], InterferometerId\[Rule]#\[LeftDoubleBracket]3\[RightDoubleBracket], DCU\[Rule]#\[LeftDoubleBracket]4\[RightDoubleBracket], NDSDataType\[Rule]#\[LeftDoubleBracket]5\[RightDoubleBracket]}&/@ info] Options[NDSGetData]={Site\[RuleDelayed]$DefaultSite,DataRate\[Rule]256, Heterodyne\[Rule]0,DataFormat\[Rule]ColumnFormat}; NDSGetData[channel_String, start_List/;VectorQ[start,NumberQ]\[And](Length[start]===2), duration_?NumberQ,opts___]:= NDSGetData[{channel},start,duration,opts] NDSGetData[channel_String, start_List/;VectorQ[start,NumberQ]\[And](Length[start]===6), duration_?NumberQ,opts___]:= NDSGetData[{channel},start,duration,opts] NDSGetData[ channel_List/;VectorQ[channel,Head[#]===String&],{gpssec_?NumberQ, gpsnsec_?NumberQ},duration_?NumberQ,opts___]:= Module[{site,drate,format,fdown,chns,data},CheckOptions[NDSGetData, opts]; site=Site/.{opts}/.Options[NDSGetData]; drate=DataRate/.{opts}/.Options[NDSGetData]; format=DataFormat/.{opts}/.Options[NDSGetData]; fdown=Heterodyne/.{opts}/.Options[NDSGetData];EstablishLink[site]; chns=ChannelArg[channel]; data=Global`ndsgetdatagps[chns,drate,fdown,gpssec,gpsnsec,duration]; CheckForErrors1[data]; If[fdown>0,data=Real2Complex/@data]; If[format===RowFormat,Transpose[data],data] ] NDSGetData[ channel_List/;VectorQ[channel,Head[#]===String&],{year_Integer, month_Integer,day_Integer,hour_Integer,min_Integer,sec_?NumberQ}, duration_?NumberQ,opts___]:= Module[{site,drate,format,fdown,chns,data},CheckOptions[NDSGetData, opts]; site=Site/.{opts}/.Options[NDSGetData]; drate=DataRate/.{opts}/.Options[NDSGetData]; format=DataFormat/.{opts}/.Options[NDSGetData]; fdown=Heterodyne/.{opts}/.Options[NDSGetData];EstablishLink[site]; chns=ChannelArg[channel]; data=Global`ndsgetdatautc[chns,drate,fdown,year,month,day,hour,min,sec, duration]; If[CheckForErrors1[data],Return[Abort[]]]; If[fdown>0,data=Real2Complex/@data]; If[format===RowFormat,Transpose[data],data] ] Options[NDSGetTrend]={Site\[RuleDelayed]$DefaultSite,DataRate\[Rule]256}; NDSGetTrend[channel_String, start_List/;VectorQ[start,NumberQ]\[And](Length[start]===2), duration_?NumberQ,opts___]:= NDSGetTrend[{channel},start,duration,opts] NDSGetTrend[channel_String, start_List/;VectorQ[start,NumberQ]\[And](Length[start]===6), duration_?NumberQ,opts___]:= NDSGetTrend[{channel},start,duration,opts] NDSGetTrend[ channel_List/;VectorQ[channel,Head[#]===String&],{gpssec_?NumberQ, gpsnsec_?NumberQ},duration_?NumberQ,opts___]:= Module[{site,drate,format,fdown,chns},CheckOptions[NDSGetTrend, opts]; site=Site/.{opts}/.Options[NDSGetTrend]; drate=DataRate/.{opts}/.Options[NDSGetTrend];EstablishLink[site]; chns=ChannelArg[channel]; CheckForErrors2[Global`ndsgettrendgps[chns,drate,gpssec,gpsnsec,duration]] ] NDSGetTrend[ channel_List/;VectorQ[channel,Head[#]===String&],{year_Integer, month_Integer,day_Integer,hour_Integer,min_Integer,sec_?NumberQ}, duration_?NumberQ,opts___]:= Module[{site,drate,format,fdown,chns},CheckOptions[NDSGetTrend, opts]; site=Site/.{opts}/.Options[NDSGetTrend]; drate=DataRate/.{opts}/.Options[NDSGetTrend];EstablishLink[site]; chns=ChannelArg[channel]; CheckForErrors2[ Global`ndsgettrendutc[chns,drate,year,month,day,hour,min,sec,duration]] ] Options[NDSTrendEliminateInvalid]={}; NDSTrendEliminateInvalid[trend_/;(And@@((MatrixQ[#,NumberQ]&)/@trend))] := Select[#,(#\[LeftDoubleBracket]2\[RightDoubleBracket]>0.9)&]&/@trend $Epilog=NDSClose; End []; (* LIGO`nds`Private` *) EndPackage []; (* LIGO`nds` *)