edu.wisc.ssec.mcidasv.data.adde
Class AddeSoundingAdapter

java.lang.Object
  extended by ucar.unidata.beans.InvisiblePropertiedBean
      extended by ucar.unidata.data.sounding.SoundingAdapterImpl
          extended by edu.wisc.ssec.mcidasv.data.adde.AddeSoundingAdapter
All Implemented Interfaces:
Serializable, PropertiedBean, SoundingAdapter

public class AddeSoundingAdapter
extends SoundingAdapterImpl
implements SoundingAdapter

Class for retrieving upper air data from an ADDE remote server. Creates a SoundingOb for each of the stations on the remote server for the latest available data.

See Also:
Serialized Form

Field Summary
private  AddeChooser addeChooser
          Used to grab accounting information for a currently selected server.
private  String dayVar
          name of day variable
private  String defaultMandDataset
          default mandatory data set
private  String defaultServer
          default server
private  String defaultSigDataset
          default significant dataset
private  String dirMandPVar
          name of mandP wind dir variable
private  String eleVar
          name of station elevation variable
protected  boolean firstTime
           
private  String htMandPVar
          name of mandP height variable
private  String idVar
          name of station id variable
private  String latVar
          name of station latitude variable
private  String lonVar
          name of station longitude variable
private  boolean mainHours
          use main hours only
private  NonVetoableProperty mandatoryDatasetProperty
          mandatory data set property
private  String mandDataset
          mandatory dataset name
private  String manDescriptor
          mandatory data descriptor
private  String manGroup
          mandatory data group name
private static String P_ALL
          all obs identifier
private static String P_DESCR
          descriptor identifier
private static String P_GROUP
          group identifier
private static String P_NUM
          number of obs identifier
private static String P_PARAM
          parameter identifier
private static String P_POS
          number of obs identifier
private static String P_SELECT
          select identifier
private  String prMandPVar
          name of mandP pressure variable
private static String proj
           
protected  boolean retry
           
private  String satellitePixel
           
private  boolean satelliteSounding
          observed or satellite sounding?
private  String satelliteTime
          these are only really used for satellite soundings
private  String server
          server name
private  NonVetoableProperty serverProperty
          server propert
private  String sigDataset
          significant dataset name
private  String sigDescriptor
          sig data descriptor
private  String sigGroup
          sig data group name
private  NonVetoableProperty significantDatasetProperty
          significant data set property
private  NonVetoableProperty soundingTimesProperty
          sounding times property
private  String spdMandPVar
          name of mandP wind speed variable
private  NonVetoableProperty stationsProperty
          stations property
private  String tdMandPVar
          name of mandP dewpoint variable
private  String timeVar
          name of time variable
private  String tpMandPVar
          name of mandP temp variable
private static String URL_PROTOCOL
          URL protocol identifier
private static String URL_ROOT
          URL type identifier
private static String user
          Accounting information
 
Fields inherited from class ucar.unidata.data.sounding.SoundingAdapterImpl
debug, defaults, haveInitialized, soundings, stations, times
 
Constructor Summary
AddeSoundingAdapter()
          Construct an empty AddeSoundingAdapter
AddeSoundingAdapter(String server)
          Retreive upper air data from a remote ADDE server using only mandatory data.
AddeSoundingAdapter(String server, String dataset)
          Retreive upper air data from a remote ADDE server using only mandatory data.
AddeSoundingAdapter(String server, String mandDataset, String sigDataset)
          Retreive upper air data from a remote ADDE server using only mandatory data.
AddeSoundingAdapter(String server, String mandDataset, String sigDataset, boolean mainHours)
          Retreive upper air data from a remote ADDE server using only mandatory data.
AddeSoundingAdapter(String server, String mandDataset, String sigDataset, boolean mainHours, AddeChooser chooser)
           
AddeSoundingAdapter(String server, String mandDataset, String sigDataset, String satelliteTime, String satellitePixel, AddeChooser chooser)
           
 
Method Summary
private  String getDflt(String name, String dflt)
          Get a default value using this Adapter's prefix
 String getMandatoryURL(SoundingOb sound)
          Make the mandatory levels URL for the given sounding
 String getMandDataset()
          Set the mandatory data set name
private  String getManUserProj()
          Get mandatory data ADDE user/project id for the data
 boolean getSatelliteSounding()
          Are we looking at satellite soundings?
private  String getServer()
           
 String getSigDataset()
          Get the significant data set name
 String getSigURL(SoundingOb sound)
          Make the url for the significant levels for the sounding
private  String getSigUserProj()
          Get significant data ADDE user/project id for the data
 String getSource()
          Get the source of the data (server)
private  String getStationsSelectString()
          Get the select string for use in loadStations
private  Unit getUnit(String unitName)
          Gets the units of the variable.
private  String getUserProj(String key)
          Get the user/project string for the given key
private  void getVariables()
          Determines the names of the variables in the netCDF file that should be used.
protected  void init()
          Initialize the class.
private  void initGroupAndDescriptors()
          Initialize the group and descriptor strings
 SoundingOb initSoundingOb(SoundingOb sound)
          Check to see if the RAOB has any data
private  boolean intEqual(int v, String s)
          Utility method that calls McIDASUtil.intBitsToString to get a string to compare to the given parameter s
private  void loadStations()
          Initialize the times, stations and soundings lists.
private  void loadStationsInner()
          Actually do the work of loading the stations
static void main(String[] args)
          test by running java ucar.unidata.data.sounding.AddeSoundingAdapter
private  String makeSelectString(SoundingOb sound)
          Make the select string that will get this observation
private  String makeSelectString(String wmoId, DateTime date)
          Make a select string for the given station id and date
private  String makeUrl(String[] args)
          Assemble the url from the given url argument array.
private  String makeUrl(String urlRoot, String[] args)
          Assemble the url from the given url root and url argument array.
private  double scaleValue(int value, int scale)
          scale the values returned from the server
 void setMandDataset(String value)
          Set the mandatory data set name
private  void setRAOBData(SoundingOb sound)
          Fills in the data for the RAOB
 void setSatelliteSounding(boolean flag)
          Change behavior if we are looking at satellite soundings
 void setSigDataset(String value)
          Set the significant data set name
 void setSource(String server)
          Set the ADDE server name
private  String sQuote(String s)
          Return the given String in single quotes
 String toString()
          The string representation
 void update()
          Update this adapter for new data
 
Methods inherited from class ucar.unidata.data.sounding.SoundingAdapterImpl
checkInit, dbPrint, getDflt, getSoundingOb, getSoundingObs, getSoundingTimes, getSoundingTimes, getStations, getStations
 
Methods inherited from class ucar.unidata.beans.InvisiblePropertiedBean
addProperty, addPropertyChangeListener, addPropertyChangeListener, disablePropertyChangeEvents, enablePropertyChangeEvents, getTitle, removePropertyChangeListener, removePropertyChangeListener, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucar.unidata.data.sounding.SoundingAdapter
getSoundingObs, getSoundingTimes, getSoundingTimes, getStations, getStations
 

Field Detail

satelliteSounding

private boolean satelliteSounding
observed or satellite sounding?


satelliteTime

private String satelliteTime
these are only really used for satellite soundings


satellitePixel

private String satellitePixel

P_PARAM

private static final String P_PARAM
parameter identifier

See Also:
Constant Field Values

P_NUM

private static final String P_NUM
number of obs identifier

See Also:
Constant Field Values

P_ALL

private static final String P_ALL
all obs identifier

See Also:
Constant Field Values

P_POS

private static final String P_POS
number of obs identifier

See Also:
Constant Field Values

P_GROUP

private static final String P_GROUP
group identifier

See Also:
Constant Field Values

P_DESCR

private static final String P_DESCR
descriptor identifier

See Also:
Constant Field Values

P_SELECT

private static final String P_SELECT
select identifier

See Also:
Constant Field Values

URL_ROOT

private static final String URL_ROOT
URL type identifier

See Also:
Constant Field Values

URL_PROTOCOL

private static final String URL_PROTOCOL
URL protocol identifier

See Also:
Constant Field Values

serverProperty

private NonVetoableProperty serverProperty
server propert


mandatoryDatasetProperty

private NonVetoableProperty mandatoryDatasetProperty
mandatory data set property


significantDatasetProperty

private NonVetoableProperty significantDatasetProperty
significant data set property


stationsProperty

private NonVetoableProperty stationsProperty
stations property


soundingTimesProperty

private NonVetoableProperty soundingTimesProperty
sounding times property


manGroup

private String manGroup
mandatory data group name


manDescriptor

private String manDescriptor
mandatory data descriptor


sigGroup

private String sigGroup
sig data group name


sigDescriptor

private String sigDescriptor
sig data descriptor


mainHours

private boolean mainHours
use main hours only


prMandPVar

private String prMandPVar
name of mandP pressure variable


htMandPVar

private String htMandPVar
name of mandP height variable


tpMandPVar

private String tpMandPVar
name of mandP temp variable


tdMandPVar

private String tdMandPVar
name of mandP dewpoint variable


spdMandPVar

private String spdMandPVar
name of mandP wind speed variable


dirMandPVar

private String dirMandPVar
name of mandP wind dir variable


dayVar

private String dayVar
name of day variable


timeVar

private String timeVar
name of time variable


idVar

private String idVar
name of station id variable


latVar

private String latVar
name of station latitude variable


lonVar

private String lonVar
name of station longitude variable


eleVar

private String eleVar
name of station elevation variable


server

private String server
server name


mandDataset

private String mandDataset
mandatory dataset name


sigDataset

private String sigDataset
significant dataset name


defaultServer

private String defaultServer
default server


defaultMandDataset

private String defaultMandDataset
default mandatory data set


defaultSigDataset

private String defaultSigDataset
default significant dataset


user

private static String user
Accounting information


proj

private static String proj

firstTime

protected boolean firstTime

retry

protected boolean retry

addeChooser

private AddeChooser addeChooser
Used to grab accounting information for a currently selected server.

Constructor Detail

AddeSoundingAdapter

public AddeSoundingAdapter()
Construct an empty AddeSoundingAdapter


AddeSoundingAdapter

public AddeSoundingAdapter(String server)
                    throws Exception
Retreive upper air data from a remote ADDE server using only mandatory data.

Parameters:
server - name or IP address of remote server
Throws:
Exception - (AddeException) if there is no data available or there is trouble connecting to the remote server

AddeSoundingAdapter

public AddeSoundingAdapter(String server,
                           String dataset)
                    throws Exception
Retreive upper air data from a remote ADDE server using only mandatory data.

Parameters:
server - name or IP address of remote server
dataset - name of ADDE dataset (group/descriptor)
Throws:
Exception - (AddeException) if there is no data available or there is trouble connecting to the remote server

AddeSoundingAdapter

public AddeSoundingAdapter(String server,
                           String mandDataset,
                           String sigDataset)
                    throws Exception
Retreive upper air data from a remote ADDE server using only mandatory data.

Parameters:
server - name or IP address of remote server
mandDataset - name of mandatory level upper air ADDE dataset (group/descriptor)
sigDataset - name of significant level upper air ADDE dataset (group/descriptor)
Throws:
Exception - (AddeException) if there is no data available or there is trouble connecting to the remote server

AddeSoundingAdapter

public AddeSoundingAdapter(String server,
                           String mandDataset,
                           String sigDataset,
                           boolean mainHours)
                    throws Exception
Retreive upper air data from a remote ADDE server using only mandatory data.

Parameters:
server - name or IP address of remote server
mandDataset - name of mandatory level upper air ADDE dataset (group/descriptor)
sigDataset - name of significant level upper air ADDE dataset (group/descriptor)
mainHours - only get data for main (00 & 12Z) hours
Throws:
Exception - (AddeException) if there is no data available or there is trouble connecting to the remote server

AddeSoundingAdapter

public AddeSoundingAdapter(String server,
                           String mandDataset,
                           String sigDataset,
                           boolean mainHours,
                           AddeChooser chooser)
                    throws Exception
Throws:
Exception

AddeSoundingAdapter

public AddeSoundingAdapter(String server,
                           String mandDataset,
                           String sigDataset,
                           String satelliteTime,
                           String satellitePixel,
                           AddeChooser chooser)
                    throws Exception
Throws:
Exception
Method Detail

init

protected void init()
             throws Exception
Initialize the class. Populate the variable list and get the server and dataset information.

Overrides:
init in class SoundingAdapterImpl
Throws:
Exception - problem occurred

intEqual

private boolean intEqual(int v,
                         String s)
Utility method that calls McIDASUtil.intBitsToString to get a string to compare to the given parameter s

Parameters:
v - integer string value
s - string to compare
Returns:
true if they are equal

sQuote

private String sQuote(String s)
Return the given String in single quotes

Parameters:
s - add single quotes to the string for select clauses
Returns:
single quoted string (ex: 'foo')

makeUrl

private String makeUrl(String[] args)
Assemble the url from the given url argument array. This turns around and calls makeUrl, passing in the URL_ROOT ("/point") and the urlRoot to use.

Parameters:
args - URL arguments, key value pairs (ex: arg[0]=arg[1]&arg[2]=arg[3]...)
Returns:
associated URL

makeUrl

private String makeUrl(String urlRoot,
                       String[] args)
Assemble the url from the given url root and url argument array. This returns: "URL_PROTOCOL://server urlRoot ?arg[0]=arg[1]&arg[2]=arg[3]...

Parameters:
urlRoot - root for the URL
args - key/value pair arguments
Returns:
ADDE URL

update

public void update()
Update this adapter for new data

Specified by:
update in interface SoundingAdapter

loadStations

private void loadStations()
Initialize the times, stations and soundings lists. Load the data into them.

Throws:
AddeException - error accessing the data

getServer

private String getServer()

initGroupAndDescriptors

private void initGroupAndDescriptors()
Initialize the group and descriptor strings


loadStationsInner

private void loadStationsInner()
                        throws AddeException
Actually do the work of loading the stations

Throws:
AddeException - problem accessing data

setSource

public void setSource(String server)
Set the ADDE server name

Specified by:
setSource in interface SoundingAdapter
Parameters:
server - server name or IP address

getSource

public String getSource()
Get the source of the data (server)

Specified by:
getSource in interface SoundingAdapter
Returns:
server name or IP address

setMandDataset

public void setMandDataset(String value)
Set the mandatory data set name

Parameters:
value - mandatory data set name

getMandDataset

public String getMandDataset()
Set the mandatory data set name

Returns:
the mandatory data set name

setSigDataset

public void setSigDataset(String value)
Set the significant data set name

Parameters:
value - the significant data set name

getSigDataset

public String getSigDataset()
Get the significant data set name

Returns:
the significant data set name

setSatelliteSounding

public void setSatelliteSounding(boolean flag)
Change behavior if we are looking at satellite soundings


getSatelliteSounding

public boolean getSatelliteSounding()
Are we looking at satellite soundings?


initSoundingOb

public SoundingOb initSoundingOb(SoundingOb sound)
Check to see if the RAOB has any data

Specified by:
initSoundingOb in interface SoundingAdapter
Specified by:
initSoundingOb in class SoundingAdapterImpl
Parameters:
sound - sounding to check
Returns:
a sounding with data

makeSelectString

private String makeSelectString(SoundingOb sound)
Make the select string that will get this observation

Parameters:
sound - sounding to use
Returns:
select string

makeSelectString

private String makeSelectString(String wmoId,
                                DateTime date)
Make a select string for the given station id and date

Parameters:
wmoId - station id
date - time of data
Returns:
ADDE select clause for the given parameters

setRAOBData

private void setRAOBData(SoundingOb sound)
Fills in the data for the RAOB

Parameters:
sound - sounding ob to set

scaleValue

private double scaleValue(int value,
                          int scale)
scale the values returned from the server

Parameters:
value - value to scale
scale - scale factor
Returns:
scaled value

getUnit

private Unit getUnit(String unitName)
Gets the units of the variable. Now just a passthrough to ucar.visad.Util.

Parameters:
unitName - unit name
Returns:
corresponding Unit or null if can't be decoded
See Also:
Util.parseUnit(String)

getDflt

private String getDflt(String name,
                       String dflt)
Get a default value using this Adapter's prefix

Parameters:
name - name of property key
dflt - default value
Returns:
the default for that property or dflt if not in properties

getVariables

private void getVariables()
Determines the names of the variables in the netCDF file that should be used.


getSigUserProj

private String getSigUserProj()
Get significant data ADDE user/project id for the data

Returns:
user/project string (ex: "id=idv proj=0")

getMandatoryURL

public String getMandatoryURL(SoundingOb sound)
Make the mandatory levels URL for the given sounding

Parameters:
sound - sounding
Returns:
mandatory url

getSigURL

public String getSigURL(SoundingOb sound)
Make the url for the significant levels for the sounding

Parameters:
sound - the sounding
Returns:
sig url

getManUserProj

private String getManUserProj()
Get mandatory data ADDE user/project id for the data

Returns:
user/project string (ex: "id=idv proj=0")

getUserProj

private String getUserProj(String key)
Get the user/project string for the given key

Parameters:
key - group/descriptor
Returns:
user/project string (ex: "id=idv proj=0") for the specified dataset

getStationsSelectString

private String getStationsSelectString()
Get the select string for use in loadStations

Returns:
select string

main

public static void main(String[] args)
test by running java ucar.unidata.data.sounding.AddeSoundingAdapter

Parameters:
args - array of arguments. Takes up to 3 arguments as "server mandatory dataset significant dataset" Use "x" for any of these arguments to use the default.

toString

public String toString()
The string representation

Overrides:
toString in class Object
Returns:
The string