au.csiro.netcdf.wron
Class ConversionUtils

java.lang.Object
  extended by au.csiro.netcdf.wron.ConversionUtils

public class ConversionUtils
extends Object

A set of common processing used for conversion of MDB SY datasets from CSV to netCDF format. Copyright 2010, CSIRO Australia All rights reserved.

Version:
$Revision: 78 $ $Date: 2010-07-24 16:23:13 +1000 (Sat, 24 Jul 2010) $
Author:
James Dempsey on 21/04/2010

Field Summary
static String ENCODING
          Encoding used to fill variables.
 
Constructor Summary
ConversionUtils()
           
 
Method Summary
 List<CellData> buildCsvFilenamesForLatitudes(List<String> lats, List<CellData> triples, String folderName, String extension)
           
 int calcDecadeKey(Integer dateKey, Date baseDate)
           
 Calendar getCalendar(Date date)
          Returns a suitable GregorianCalendar instance for use in date calculations.
 TimeZone getGoodZone()
          returns a TimeZone with correct Sydney daylight saving regime - ie correct server timezone.
 List<String> getLatitudeBlock(Set<String> sortedLatitudes, int blockNum, int blockSize)
          Retrieve the block of latitudes to be processed.
 Set<String> getLimitedLatitudes(Set<String> allLatitudes, String startingLatitude, String endingLatitude)
          Retrieve the latitudes within the bounds provided.
 Map<Integer,Map<String,LongitudeRange>> readDataByLatitudes(List<CellData> targetCells, List<String> lats, int numVariables, int numTimes, int numLongitudes, String[] fillValues, String startLongitudeRange)
          Read in the data from the CSV files.
 void writeLatDataByDecade(Map<Integer,Map<String,LongitudeRange>> latData, Map<Integer,String[]> allFilenames, String[] variableNames, Date baseDate)
          Write out the data for each variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING

public static final String ENCODING
Encoding used to fill variables.

See Also:
Constant Field Values
Constructor Detail

ConversionUtils

public ConversionUtils()
Method Detail

getLimitedLatitudes

public Set<String> getLimitedLatitudes(Set<String> allLatitudes,
                                       String startingLatitude,
                                       String endingLatitude)
Retrieve the latitudes within the bounds provided.

Parameters:
allLatitudes - The list of latitudes in numerical order
startingLatitude - The first (numerically -38 < -24) latitude to be included
endingLatitude - The last (numerically -38 < -24) latitude to be included
Returns:
The set of latitudes in the range

getLatitudeBlock

public List<String> getLatitudeBlock(Set<String> sortedLatitudes,
                                     int blockNum,
                                     int blockSize)
Retrieve the block of latitudes to be processed.

Parameters:
sortedLatitudes - The list of latitudes in numerical order
blockNum - The block of latitudes to be retrieved
blockSize - The number of latitudes in a block
Returns:
The latitudes in the block

buildCsvFilenamesForLatitudes

public List<CellData> buildCsvFilenamesForLatitudes(List<String> lats,
                                                    List<CellData> triples,
                                                    String folderName,
                                                    String extension)

readDataByLatitudes

public Map<Integer,Map<String,LongitudeRange>> readDataByLatitudes(List<CellData> targetCells,
                                                                   List<String> lats,
                                                                   int numVariables,
                                                                   int numTimes,
                                                                   int numLongitudes,
                                                                   String[] fillValues,
                                                                   String startLongitudeRange)
Read in the data from the CSV files. The data is returned as a double map keyed on time index (days since epoch) and latitude of LongitudeRanges. Each LongitudeRange will contain the values for each variable at each each longitude point within the latitude.

Parameters:
targetCells - The cells to be read. Each cell should have a populated filename (including full path)
lats - The latitudes being processed.
numVariables - The number of variables held in each csv file (all MUST be read).
numTimes - The number of times expected in each CSV file.
fillValues - The data any missing entries are to be filled with.
Returns:
The variables data from the files

writeLatDataByDecade

public void writeLatDataByDecade(Map<Integer,Map<String,LongitudeRange>> latData,
                                 Map<Integer,String[]> allFilenames,
                                 String[] variableNames,
                                 Date baseDate)
                          throws IOException
Write out the data for each variable.

Parameters:
latData - The data to be output
allFilenames - The filenames for each decade and variable
variableNames - The names of the variables to be written
baseDate - The startdate of the data (i.e. the date a date value of 0 is)
Throws:
IOException - If the data cannot be written.

calcDecadeKey

public int calcDecadeKey(Integer dateKey,
                         Date baseDate)

getGoodZone

public TimeZone getGoodZone()
returns a TimeZone with correct Sydney daylight saving regime - ie correct server timezone.


getCalendar

public Calendar getCalendar(Date date)
Returns a suitable GregorianCalendar instance for use in date calculations.

Parameters:
date - The date to be set.
Returns:
GregorianCalendar A calendar instance for the ACT timezone.


Copyright © 2010. All Rights Reserved.