Class TMYdata

java.lang.Object
  |
  +--TMYdata

public class TMYdata
extends java.lang.Object
implements CWmonitorable

The TMYdata class defines an object to hold a 1-year TMY (Typical Meteorological Year) data set, and methods to access that data.

Creating an instance of this class does not initialize data. That is done using the readData() method. Different varieties of this can read either stream input or a file. Data can be in TMY format or the SOLMET format. Also, it can be in compressed (.gz) format.

Creating the TMYdata class causes it to register its monitorable elements with the CWmonitoredElements class.


Field Summary
static int APRIL
          Used to specify a month to a method.
static int AUGUST
          Used to specify a month to a method.
static int CDD
          Identifier specifying the type of query being made of getDegreeDays().
static int DAILY_AVERAGE
          Used to specify data filtering.
static int DAILY_HIGH
          Used to specify data filtering.
static int DAILY_LOW
          Used to specify data filtering.
static int DAILY_NO_FILTER
          Used to specify data filtering.
static java.lang.String[] days
          An array of 31 day identifiers corresponding to the day indices used in this object.
static int DECEMBER
          Used to specify a month to a method.
static int DEWPOINT
          Used to identify a field.
static int DIFFUSE_HORIZONTAL_RADIATION
          Used to identify a field.
static int DIRECT_NORMAL_RADIATION
          Used to identify a field.
static int DRY_BULB_TEMP
          Used to identify a field.
static int FEBRUARY
          Used to specify a month to a method.
static int[] field_types
           
static java.lang.String[] fields
          Names of TMY fields stored in this object.
static int GLOBAL_HORIZONTAL_RADIATION
          Used to identify a field.
static int HDD
          Identifier specifying the type of query being made of getDegreeDays().
static java.lang.String[] hours
          An array of 24 hour identifiers corresponding to the hour indices used in this object.
static java.lang.String[] hours12
           
static int JANUARY
          Used to specify a month to a method.
static int JULY
          Used to specify a month to a method.
static int JUNE
          Used to specify a month to a method.
 SOLlocation location
           
static int MARCH
          Used to specify a month to a method.
static int MAY
          Used to specify a month to a method.
static int[] MONTHLENGTH
          12-element array specifying the number of days in the 12 months.
static java.lang.String[] MONTHS
          An array of 12 Month identifiers corresponding to the month indices used in this object.
static int NOVEMBER
          Used to specify a month to a method.
static int OCTOBER
          Used to specify a month to a method.
static int RELATIVE_HUMIDITY
          Used to identify a field.
static int SEPTEMBER
          Used to specify a month to a method.
 double[][][][] tmydat
          4-dimensional array holding TMY data.
 boolean use_metric
          Tells whether we are using metric or english units.
static int WIND_DIRECTION
          Used to identify a field.
static int WIND_SPEED
          Used to identify a field.
 
Method Summary
static int dayOfYear(int month, int day_of_month)
           
static int daysInMonth(int month)
          Returns the number of days in the specified month
 double getAverageValue(int fieldnum)
          Calculates the average of some field over the period of a year.
 double getAverageValue(int month, int fieldnum)
          Calculates the average value of some field over the period of a month.
 double getAverageValue(int month, int day, int fieldnum)
          Calculates the average value of some field over the period of a day
 java.lang.String getCity()
          Returns the name of the City of the data collection station.
 double[][] getDailyFilteredData(int first_month, int last_month, int filter_type, int fieldnum)
          Extract monthly values from the TMY dataset for a period of time.
 double getDegreeDays(int heatcool, double base)
          Calculate degree days for one year.
 double getDegreeDays(int month, int heatcool, double base)
          Calculate degree days for one month.
 double getDegreeDays(int month, int day, int heatcool, double base)
          Finds heating or cooling degree days over one day.
 java.lang.String[] getFields()
          Returns the list of monitorable fields.
 int[] getFieldTypes()
          Returns the list of types of the monitorable fields.
 double getHighValue(int[] fieldnums)
          Finds the maximum value of a set of fields over the period of a year.
 double getHighValue(int month, int[] fieldnums)
          Finds the maximum value of a set of fields over the period of a month.
 double getHighValue(int month, int day, int[] fieldnums)
          Finds the maximum value of a set of fields over the period of a day.
 double getLowValue(int[] fieldnums)
          Finds the minimum value of a set of fields over the period of a year.
 double getLowValue(int month, int[] fieldnums)
          Finds the minimum value of a field over the period of a month.
 double getLowValue(int month, int day, int[] fieldnums)
          Finds the minimum value of a set of fields over the period of a day.
 java.lang.String getName()
          Returns the name (City,State) of the location.
 java.lang.String getState()
          Returns the name of the State of the data collecton station.
 double getValue(int month, int day, int hour, int fieldnum)
          Returns a data value for the specified month, day, hour and field number.
 int getWBAN()
          Returns the WBAN number of the station.
static int hourOfYear(int month, int day, int hour)
          Given month (0-11), day(0-31), and hour, return the hour in the year.
 void readData(java.io.File file)
          Read a TMY2 file into the TMYdata object.
 void readData(java.io.InputStream is)
          Read TMY2 data from an InputStream.
 void readData(java.io.InputStream input_stream, java.lang.String fname)
          Read a TMY2 file into the TMYdata object.
 void readData(java.lang.String fname)
           
 int readTMYStream(java.io.BufferedReader br)
          Reads a TMY or SOLMET format data file, creating data structures.
 boolean setValue(int month, int day, int hour, int fieldnum, double value)
          Sets the data value for the specified month, day, hour and field number.
 void useEnglish()
          Sets the object to use English units in all data exchanges.
 void useMetric()
          Sets the object to use Metric units in data exchanges.
 boolean usingMetric()
          Returns true if the object is set for Metric units, false for English units.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HDD

public static final int HDD
Identifier specifying the type of query being made of getDegreeDays().

CDD

public static final int CDD
Identifier specifying the type of query being made of getDegreeDays().

MONTHLENGTH

public static int[] MONTHLENGTH
12-element array specifying the number of days in the 12 months.

fields

public static final java.lang.String[] fields
Names of TMY fields stored in this object.

field_types

public static final int[] field_types

MONTHS

public static final java.lang.String[] MONTHS
An array of 12 Month identifiers corresponding to the month indices used in this object. Possibly useful as labels.

days

public static final java.lang.String[] days
An array of 31 day identifiers corresponding to the day indices used in this object. Possibly useful as labels.

hours

public static final java.lang.String[] hours
An array of 24 hour identifiers corresponding to the hour indices used in this object. Possibly useful as labels.

hours12

public static final java.lang.String[] hours12

GLOBAL_HORIZONTAL_RADIATION

public static final int GLOBAL_HORIZONTAL_RADIATION
Used to identify a field. Field identifier for Global Horizontal Radiation.

DIRECT_NORMAL_RADIATION

public static final int DIRECT_NORMAL_RADIATION
Used to identify a field. Field identifier for Direct Normal Radiation.

DIFFUSE_HORIZONTAL_RADIATION

public static final int DIFFUSE_HORIZONTAL_RADIATION
Used to identify a field. Field identifier for Diffuse Horizontal Radiation.

DRY_BULB_TEMP

public static final int DRY_BULB_TEMP
Used to identify a field. Field identifier for Dry Bulb Temperature.

DEWPOINT

public static final int DEWPOINT
Used to identify a field. Field identifier for Dewpoint.

RELATIVE_HUMIDITY

public static final int RELATIVE_HUMIDITY
Used to identify a field. Field identifier for Relative Humidity.

WIND_DIRECTION

public static final int WIND_DIRECTION
Used to identify a field. Field identifier for Wind Direction.

WIND_SPEED

public static final int WIND_SPEED
Used to identify a field. Field Identifier for Wind Direction.

JANUARY

public static final int JANUARY
Used to specify a month to a method. January.

FEBRUARY

public static final int FEBRUARY
Used to specify a month to a method. February.

MARCH

public static final int MARCH
Used to specify a month to a method. March.

APRIL

public static final int APRIL
Used to specify a month to a method. April.

MAY

public static final int MAY
Used to specify a month to a method. May.

JUNE

public static final int JUNE
Used to specify a month to a method. June.

JULY

public static final int JULY
Used to specify a month to a method. July.

AUGUST

public static final int AUGUST
Used to specify a month to a method. August.

SEPTEMBER

public static final int SEPTEMBER
Used to specify a month to a method. September.

OCTOBER

public static final int OCTOBER
Used to specify a month to a method. October.

NOVEMBER

public static final int NOVEMBER
Used to specify a month to a method. November.

DECEMBER

public static final int DECEMBER
Used to specify a month to a method. December.

DAILY_NO_FILTER

public static final int DAILY_NO_FILTER
Used to specify data filtering. Don't filter daily data.

DAILY_AVERAGE

public static final int DAILY_AVERAGE
Used to specify data filtering. Take daily average of data

DAILY_HIGH

public static final int DAILY_HIGH
Used to specify data filtering. Keep the daily high.

DAILY_LOW

public static final int DAILY_LOW
Used to specify data filtering. keep the daily low.

location

public SOLlocation location

tmydat

public double[][][][] tmydat
4-dimensional array holding TMY data. First index selects month. (JANUARY, FEBRUARY, etc). second index selects day in month (0-30). Third index selects hour in day. Fourth index selects the data field.

use_metric

public boolean use_metric
Tells whether we are using metric or english units. Default is true.
Method Detail

readTMYStream

public int readTMYStream(java.io.BufferedReader br)
                  throws java.io.IOException
Reads a TMY or SOLMET format data file, creating data structures. Decides on file format based on slight differences in the first (header) line. Returns 0 on normal completion, 1 otherwise.

readData

public void readData(java.lang.String fname)
              throws java.io.FileNotFoundException,
                     java.io.IOException

readData

public void readData(java.io.File file)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Read a TMY2 file into the TMYdata object. Argument is a File. If the filename ends with .zip or .gz, appropriate decompression is performed.

readData

public void readData(java.io.InputStream input_stream,
                     java.lang.String fname)
              throws java.io.IOException
Read a TMY2 file into the TMYdata object. Argument is a File. If the filename ends with .zip or .gz, appropriate decompression is performed.

readData

public void readData(java.io.InputStream is)
              throws java.io.IOException
Read TMY2 data from an InputStream.

getValue

public double getValue(int month,
                       int day,
                       int hour,
                       int fieldnum)
Returns a data value for the specified month, day, hour and field number.
Specified by:
getValue in interface CWmonitorable

getAverageValue

public double getAverageValue(int month,
                              int day,
                              int fieldnum)
Calculates the average value of some field over the period of a day

getAverageValue

public double getAverageValue(int month,
                              int fieldnum)
Calculates the average value of some field over the period of a month.

getAverageValue

public double getAverageValue(int fieldnum)
Calculates the average of some field over the period of a year.

getHighValue

public double getHighValue(int month,
                           int day,
                           int[] fieldnums)
Finds the maximum value of a set of fields over the period of a day. When used on a single field, is useful for determining things like high temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getHighValue

public double getHighValue(int month,
                           int[] fieldnums)
Finds the maximum value of a set of fields over the period of a month. When used on a single field, is useful for determining things like high temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getHighValue

public double getHighValue(int[] fieldnums)
Finds the maximum value of a set of fields over the period of a year. When used on a single field, is useful for determining things like high temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getLowValue

public double getLowValue(int month,
                          int day,
                          int[] fieldnums)
Finds the minimum value of a set of fields over the period of a day. When used on a single field, is useful for determining things like low temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getLowValue

public double getLowValue(int month,
                          int[] fieldnums)
Finds the minimum value of a field over the period of a month. When used on a single field, is useful for determining things like low temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getLowValue

public double getLowValue(int[] fieldnums)
Finds the minimum value of a set of fields over the period of a year. When used on a single field, is useful for determining things like low temperatures. If multiple fields are specified, useful for determining bounds before plotting.

getDegreeDays

public double getDegreeDays(int month,
                            int day,
                            int heatcool,
                            double base)
Finds heating or cooling degree days over one day. Specify HDD for heatcool if heating degree days are desired. Specify CDD for cooling degree days. base specifies the temperature base used.

getDegreeDays

public double getDegreeDays(int month,
                            int heatcool,
                            double base)
Calculate degree days for one month. Specify HDD for heatcool if heating degree days are desired. Specify CDD for cooling degree days. base specifies the temperature base used.

getDegreeDays

public double getDegreeDays(int heatcool,
                            double base)
Calculate degree days for one year. Specify HDD for heatcool if heating degree days are desired. Specify CDD for cooling degree days. base specifies the temperature base used.

useMetric

public void useMetric()
Sets the object to use Metric units in data exchanges.

useEnglish

public void useEnglish()
Sets the object to use English units in all data exchanges.

usingMetric

public boolean usingMetric()
Returns true if the object is set for Metric units, false for English units.

getWBAN

public int getWBAN()
Returns the WBAN number of the station.

getCity

public java.lang.String getCity()
Returns the name of the City of the data collection station.

getState

public java.lang.String getState()
Returns the name of the State of the data collecton station.

getName

public java.lang.String getName()
Returns the name (City,State) of the location. Part of the CWmonitorable interface.
Specified by:
getName in interface CWmonitorable

getFields

public java.lang.String[] getFields()
Returns the list of monitorable fields. Part of the CWmonitorable interface.
Specified by:
getFields in interface CWmonitorable

getFieldTypes

public int[] getFieldTypes()
Returns the list of types of the monitorable fields. Part of the CWmonitorable interface. Used for unit conversions. Types are defined in class UnitConverter.
Specified by:
getFieldTypes in interface CWmonitorable

hourOfYear

public static int hourOfYear(int month,
                             int day,
                             int hour)
Given month (0-11), day(0-31), and hour, return the hour in the year.

dayOfYear

public static int dayOfYear(int month,
                            int day_of_month)

daysInMonth

public static int daysInMonth(int month)
Returns the number of days in the specified month

setValue

public boolean setValue(int month,
                        int day,
                        int hour,
                        int fieldnum,
                        double value)
Sets the data value for the specified month, day, hour and field number.

getDailyFilteredData

public double[][] getDailyFilteredData(int first_month,
                                       int last_month,
                                       int filter_type,
                                       int fieldnum)
Extract monthly values from the TMY dataset for a period of time. Result is a 2-dimensional array. filter_type is one of DAILY_HIGH, DAILY_LOW, DAILY_AVERAGE, DAILY_NO_FILTER. Returned value: val[0] = time, val[1] = data value.