## edu.wisc.ssec.mcidas
Class McIDASUtil

    java.lang.Object
      edu.wisc.ssec.mcidas.McIDASUtil

public final class McIDASUtil
extends Object

Class for static McIDAS utility methods. In many cases, these methods are the Java equivalents of McIDAS library functions.

See Also:
  McIDAS Programmer's Manual

Field Summary
`static int` `MCMISSING` McIDAS missing value for 4-byte integers

Constructor Summary
`McIDASUtil()`

Method Summary
`static int` `bytesToInteger(byte[] b, int off)` convert four consequtive bytes into a (signed) int.
`static int[]` `bytesToIntegerArray(byte[] b, int off, int num)` convert consequtive bytes into a (signed) int array.
`static int` `doubleLatLonToInteger(double dvalue)` Converts a double latitude/longitude to a packed integer (SIGN DDD MM SS) Java version of McIDAS `ilalo` function.
`static void` `flip(int[] array, int first, int last)` Flip the bytes of an integer array.
`static AreaFile` `getAreaFile(String filename)` De-serialize an AreaFile object from disk
`static String` `intBitsToString(int value)` convert signed int to a String representation.
`static String` `intBitsToString(int[] values)` convert signed int array to a String representation.
`static double` `integerLatLonToDouble(int value)` Converts a packed integer (SIGN DDD MM SS) latitude/longitude to double.
`static boolean` `isChar(int value)` Check to see if the int value is the representation of a string or not.
`static GregorianCalendar` `makeCalendarForDayTimeToSecs()` Create a calendar to be used for mcDayTimeToSecs.
`static long` `mcDateHmsToSecs(int date, int time)` Convert date (yyyymmdd or yyyymmdd) and hms (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT).
`static long` `mcDayTimeToSecs(int yearday, int time)` Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT).
`static long` `mcDayTimeToSecs(int yearday, int time, GregorianCalendar cal)` Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT).
`static int` `mcDoubleToPackedInteger(double dvalue)` Converts a double latitude/longitude or time (hours) to a packed integer (SIGN DDD/HH MM SS).
`static double` `mcPackedIntegerToDouble(int value)` Converts a packed integer (SIGN DDD/HH MM SS) latitude/longitude or time (hours) to double.
`static int[]` `mcSecsToDayTime(long secs)` Convert seconds since the epoch (January 1, 1970, 00:00GMT) to day (yyyyddd) and time (hhmmss).
`static boolean` `putAreaFile(String filename, AreaFile af)` Serialize an AreaFile object to disk
`static double` `timdif(int yrday1, int hms1, int yrday2, int hms2)` Calculate difference in minutes between two dates/times.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MCMISSING

    public static final int MCMISSING

  McIDAS missing value for 4-byte integers

  See Also:
    Constant Field Values

Constructor Detail

### McIDASUtil

    public McIDASUtil()

Method Detail

### integerLatLonToDouble

    public static double integerLatLonToDouble(int value)

  Converts a packed integer (SIGN DDD MM SS) latitude/longitude to double. Java version of McIDAS `flalo` function except returns a double instead of a float.

  Parameters:
    `value` - integer containing the packed data
  Returns:
    double representation of value

### doubleLatLonToInteger

    public static int doubleLatLonToInteger(double dvalue)

  Converts a double latitude/longitude to a packed integer (SIGN DDD MM SS) Java version of McIDAS `ilalo` function.

  Returns:
    packed integer representation of value

### mcPackedIntegerToDouble

    public static double mcPackedIntegerToDouble(int value)

  Converts a packed integer (SIGN DDD/HH MM SS) latitude/longitude or time (hours) to double. Java replacements of McIDAS `flalo` and `ftime` functions except returns a double instead of a float.

  Parameters:
    `value` - integer containing the packed data
  Returns:
    double representation of value

### mcDoubleToPackedInteger

    public static int mcDoubleToPackedInteger(double dvalue)

  Converts a double latitude/longitude or time (hours) to a packed integer (SIGN DDD/HH MM SS). Java replacements of McIDAS `ilalo` and `m0itime` functions.

  Returns:
    packed integer representation of value

### timdif

    public static double timdif(int yrday1,
                                int hms1,
                                int yrday2,
                                int hms2)

  Calculate difference in minutes between two dates/times. Java version of timdif.for

  Parameters:
    `yrday1` - Year/day of first time (yyddd or yyyyddd)
    `hms1` - Hours/minutes/seconds of first time (hhmmss).
    `yrday2` - Year/day of second time (yyddd).
    `hms2` - Hours/minutes/seconds of second time (hhmmss).
  Returns:
    The difference between the two times (time2 - time1), in minutes. If the first time is greater than the second, the result will be negative.

### makeCalendarForDayTimeToSecs

    public static GregorianCalendar makeCalendarForDayTimeToSecs()

  Create a calendar to be used for mcDayTimeToSecs. Use this to minimize object creation overhead when calling the method many times.

  Returns:
    A calendar to use for mcDayTimeToSecs.

### mcDayTimeToSecs

    public static long mcDayTimeToSecs(int yearday,
                                       int time)

  Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT). Java version of 'mcdaytimetosecs' except it returns a long instead of an int.

  Parameters:
    `yearday` - year/day in either yyddd or yyyyddd format. Only works for years > 1900.
    `time` - time in packed integer format (hhmmss)
  Returns:
    seconds since the epoch

### mcDayTimeToSecs

    public static long mcDayTimeToSecs(int yearday,
                                       int time,
                                       GregorianCalendar cal)

  Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT). Java version of 'mcdaytimetosecs' except it returns a long instead of an int.

  Parameters:
    `yearday` - year/day in either yyddd or yyyyddd format. Only works for years > 1900.
    `time` - time in packed integer format (hhmmss)
    `cal` - If non-null then use this calendar to do the formatting. else create a new one. Note: The calendar you pass in should be one created from makeCalendarForDayTimeToSecs
  Returns:
    seconds since the epoch

### mcDateHmsToSecs

    public static long mcDateHmsToSecs(int date,
                                       int time)

  Convert date (yyyymmdd or yyyymmdd) and hms (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT).

  Parameters:
    `date` - year/day in yyymmdd format. Only works for years > 1900.
    `time` - time in packed integer format (hhmmss)
  Returns:
    seconds since the epoch

### mcSecsToDayTime

    public static int[] mcSecsToDayTime(long secs)

  Convert seconds since the epoch (January 1, 1970, 00:00GMT) to day (yyyyddd) and time (hhmmss). Java version of 'mcsecstodaytime' except it returns an int array instead of pointers

  Parameters:
    `secs` - seconds since the epoch
  Returns:
    int[2] array with day (yyyyddd) as first element and time (hhmmss - packed integer) as second element.

### flip

    public static void flip(int[] array,
                            int first,
                            int last)

  Flip the bytes of an integer array. Java version of 'm0swbyt4'.

  Parameters:
    `first` - starting element of the array
    `last` - last element of array to flip

### bytesToInteger

    public static int bytesToInteger(byte[] b,
                                     int off)

  convert four consequtive bytes into a (signed) int. This is useful in dealing with McIDAS data files.

  Parameters:
    `off` - is the offset into the byte array

### bytesToIntegerArray

    public static int[] bytesToIntegerArray(byte[] b,
                                            int off,
                                            int num)

  convert consequtive bytes into a (signed) int array. This is useful in dealing with McIDAS data files.

  Parameters:
    `off` - is the offset into the byte array
    `num` - number of integers to create

### intBitsToString

    public static String intBitsToString(int value)

  convert signed int to a String representation. This is useful in dealing with McIDAS data files. Java version of 'clit'.

  Parameters:
    `value` - - integer representation of a string
  Returns:
    String representation of the int

### intBitsToString

    public static String intBitsToString(int[] values)

  convert signed int array to a String representation. This is useful in dealing with McIDAS data files. Java version of 'movwc'.

  Parameters:
    `values` - - integer array representation of a string
  Returns:
    String representation of the int array

### isChar

    public static boolean isChar(int value)

  Check to see if the int value is the representation of a string or not. Java version of ischar_.c (sort of).

  Parameters:
    `value` - integer representation
  Returns:
    true if the int represents a string

### putAreaFile

    public static boolean putAreaFile(String filename,
                                      AreaFile af)

  Serialize an AreaFile object to disk

  Parameters:
    `filename` - - name of disk file to write to
  Returns:
    true if no Exception; false otherwise

### getAreaFile

    public static AreaFile getAreaFile(String filename)

  De-serialize an AreaFile object from disk

  Parameters:
    `filename` - - name of disk file to read
  Returns:
    AreaFile if okay; null otherwise