Java Temperature to Radiance brightnessTemp_to_radiance(float[][] values, int band_number)

Here you can find the source of brightnessTemp_to_radiance(float[][] values, int band_number)

Description

brightness Temtradiance

License

Open Source License

Declaration

public static float[][] brightnessTemp_to_radiance(float[][] values, int band_number) throws Exception 

Method Source Code

//package com.java2s;
/*/*from w  w w .  j a v a2  s  .  co  m*/
 * This file is part of McIDAS-V
 *
 * Copyright 2007-2015
 * Space Science and Engineering Center (SSEC)
 * University of Wisconsin - Madison
 * 1225 W. Dayton Street, Madison, WI 53706, USA
 * http://www.ssec.wisc.edu/mcidas
 * 
 * All Rights Reserved
 * 
 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
 * some McIDAS-V source code is based on IDV and VisAD source code.  
 * 
 * McIDAS-V is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * McIDAS-V is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser Public License
 * along with this program.  If not, see http://www.gnu.org/licenses.
 */

public class Main {
    /**
    Emissive bands
    taken from pfm-in-band-rsr.pdf (Aqua)
        
    band center width (m*10E6)
    begin end
    ------------------------------------
    20 3.799 3.660 3.840
    21 3.992 3.929 3.989
    22 3.968 3.929 3.989
    23 4.070 4.020 4.080
    24 4.476 4.433 4.498
    25 4.549 4.482 4.549
    27 6.784 6.535 6.895
    28 7.345 7.175 7.475
    29 8.503 8.400 8.700
    30 9.700 9.580 9.880
    31 11.000 10.780 11.280
    32 12.005 11.770 12.270
    33 13.351 13.185 13.485
    34 13.717 13.485 13.785
    35 13.908 13.785 14.085
    36 14.205 14.085 14.385
    **/

    //... Effective central wavelengths (micrometers)
    static double[] cwl_aqua = { 3.799, 3.992, 3.968, 4.070, 4.476, 4.549, 6.784, 7.345, 8.503, 9.700, 11.000,
            12.005, 13.351, 13.717, 13.908, 14.205 };

    public static float[][] brightnessTemp_to_radiance(float[][] values, int band_number) throws Exception {
        int index = getIndexFromBandNumber(band_number);
        return new float[][] { brightnessTemp_to_radiance(values[0], (float) cwl_aqua[index]) };
    }

    public static float[] brightnessTemp_to_radiance(float[] values, float wavelength) {

        // Constants are from "The Fundamental Physical Constants",
        // Cohen, E. R. and B. N. Taylor, Physics Today, August 1993.

        double w = (double) wavelength;

        // Planck constant (Joule second)
        double h = 6.6260755e-34;

        // Speed of light in vacuum (meters per second)
        double c = 2.9979246e8;

        // Boltzmann constant (Joules per Kelvin)
        double k = 1.380658e-23;

        // Derived constants
        double c1 = 2.0 * h * c * c;
        double c2 = (h * c) / k;

        // Convert wavelength to meters
        double ws = 1.0e-6 * w;

        // Compute brightness temperature
        float[] new_values = new float[values.length];
        for (int i = 0; i < values.length; i++) {
            double t = (double) values[i];
            new_values[i] = (float) ((1.0e-6 * (c1 / (ws * ws * ws * ws * ws))) / (Math.exp(c2 / (ws * t)) - 1.0));
        }

        return new_values;
    }

    public static int getIndexFromBandNumber(int band_number) throws Exception {

        if ((band_number < 20) || (band_number > 36) || (band_number == 26)) {
            throw new Exception("bad band number: " + band_number + " band 20-36 but not 26");
        }

        int index;

        if (band_number <= 25) {
            index = band_number - 19;
        } else {
            index = band_number - 20;
        }
        index -= 1;

        return index;
    }
}