Documentation of 'edu.wisc.ssec.mcidas.McIDASUtil' Java class
McIDASUtil
edu.wisc.ssec.mcidas

Class McIDASUtil



  • public final class McIDASUtil
    extends java.lang.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

      Fields 
      Modifier and Type Field and Description
      static int MCMISSING
      McIDAS missing value for 4-byte integers
    • Constructor Summary

      Constructors 
      Constructor and Description
      McIDASUtil() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      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 consecutive 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(java.lang.String filename)
      De-serialize an AreaFile object from disk
      static java.lang.String intBitsToString(int value)
      convert signed int to a String representation.
      static java.lang.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 java.util.GregorianCalendar makeCalendarForDayTimeToSecs()
      Create a calendar to be used for mcDayTimeToSecs.
      static long mcDateHmsToSecs(int date, int time)
      Convert date (yymmdd 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, java.util.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 java.lang.String mcHmsToStr(int hms)
      Convert an HMS integer to a string of form 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 java.lang.String padLeft(java.lang.String s, int desiredLength, java.lang.String padString)
      Pad the given string with padString on the left up to the given length.
      static java.lang.String padZero(int value, int numDigits)
      Left pad the given value with zeros up to the number of digits
      static boolean putAreaFile(java.lang.String filename, AreaFile af)
      Serialize an AreaFile object to disk
      static int swbyt4(int val)
      Flip the bytes of an integer.
      static void swbyt4(int[] array, int first, int num)
      Flip the bytes of an integer array.
      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

        equals, 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.
        Parameters:
        dvalue - double value of lat/lon
        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.
        Parameters:
        dvalue - double value of lat/lon or time
        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 java.util.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,
                                           java.util.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 (yymmdd 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.
      • mcHmsToStr

        public static java.lang.String mcHmsToStr(int hms)
        Convert an HMS integer to a string of form hh:mm:ss.
        Parameters:
        hms - integer hhmmss
        Returns:
        string representation
      • padZero

        public static java.lang.String padZero(int value,
                                               int numDigits)
        Left pad the given value with zeros up to the number of digits
        Parameters:
        value - The value.
        numDigits - number of digits
        Returns:
        The String represenation of the value, padded with leading "0"-s if value < 10E(numDigits-1)
      • padLeft

        public static java.lang.String padLeft(java.lang.String s,
                                               int desiredLength,
                                               java.lang.String padString)
        Pad the given string with padString on the left up to the given length.
        Parameters:
        s - String to pad
        desiredLength - ending length
        padString - String to pad with (e.g, " ")
        Returns:
        padded String
      • swbyt4

        public static int swbyt4(int val)
        Flip the bytes of an integer.
        Parameters:
        val - value to swap
        Returns:
        the flipped integer
      • swbyt4

        public static void swbyt4(int[] array,
                                  int first,
                                  int num)
        Flip the bytes of an integer array. Java version of 'm0swbyt4'.
        Parameters:
        array - array of integers to be flipped
        first - starting element of the array
        num - number of values to swap
      • flip

        public static void flip(int[] array,
                                int first,
                                int last)
        Flip the bytes of an integer array. Java version of 'm0swbyt4'.
        Parameters:
        array - array of integers to be flipped
        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:
        b - array of 4 bytes
        off - is the offset into the byte array
        Returns:
        the integer value
      • bytesToIntegerArray

        public static int[] bytesToIntegerArray(byte[] b,
                                                int off,
                                                int num)
        convert consecutive bytes into a (signed) int array. This is useful in dealing with McIDAS data files.
        Parameters:
        b - array of bytes
        off - is the offset into the byte array
        num - number of integers to create
        Returns:
        the array of values as integers
      • intBitsToString

        public static java.lang.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 java.lang.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(java.lang.String filename,
                                          AreaFile af)
        Serialize an AreaFile object to disk
        Parameters:
        filename - - name of disk file to write to
        af -
        Returns:
        true if no Exception; false otherwise
      • getAreaFile

        public static AreaFile getAreaFile(java.lang.String filename)
        De-serialize an AreaFile object from disk
        Parameters:
        filename - - name of disk file to read
        Returns:
        AreaFile if okay; null otherwise

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.