Java code instance and java instance
Package Core. atmRadi; import ij. imagePlus; import ij. io. fileSaver; import ij. process. floatProcessor; import ij. process. imageProcessor; import java. io. file; import java. io. fileWriter; import java. io. IOException; import java. util. arrayList; import java. util. hashMap; import java. util. list; import java. util. map; import CommonUtil. callModtran. callModtran; import CommonUtil. fileIO. readSSRFile; import Core. atmRadi. atmC Orec1c. band; import Core. atmRadi. ATM corecalc. bandLsLh; import Core. atmRadi. ATM corecalc. discreteLsLh; import Core. atmRadi. ATM corecalc. genDiscreteLsLh; import Core. atmRadi. ATM corecalc. pathTerm; import Core. atmRadi. ATM corecalc. solveEq; import Core. atmRadi. ATM corecalc. tape7Columns; import Core. atmRadi. ATM corecalc. utility; import XMLBean. xmlUtil; import XMLBean. atmRadi. param. ATM condientity; import XMLBean. atmRa Di. param. geoPathEntity; import XMLBean. atmRadi. param. spectralEntity; public class ATM module {private String bandInfoPath; private String atmParasPath; private String refPath; private String resultPath; private String xmlFilePath = "C: /Users/Administrator/workspace/IJ/XML/AtmRadi_Param.xml "; private Map <String, String> parasMap; private Map <String, String> parasMapLast; private List <PathTerm> pathTe RmList; private List <Band> bandInfoList; public static void main (String [] args) {atm module atm = new atm module (); atm. init (". /shortname ", null ,". /MOD09A1/ref. tif ",". /"); try {atm. run ();} catch (IOException e) {e. printStackTrace () ;}} private void setAtmParas () {// parse the corresponding xml file: Convert the xml file to a java object. XmlUtil contains the tool function List <ATM condientity> ATM condientities = XmlUtil. XMLToObj (xmlFilePath, ATM condientity. class); List <GeoPathEntity> geoPathEntities = XmlUtil. XMLToObj (xmlFilePath, GeoPathEntity. class); List <SpectralEntity> spectralEntities = XmlUtil. XMLToObj (xmlFilePath, SpectralEntity. class); parasMap = new HashMap <String, String> (); // Card1 parasMap. put ("MODEL", String. valueOf (ATM condientities. get (0 ). getatm mode (); // atmospheric mode // Card1A parasMap. put ("H2OSTR", String. valueOf (ATM condientities. get (0 ). getH2O (); // The characteristics of the vertical vapor column parasMap. put ("O3STR", String. valueOf (ATM condientities. get (0 ). getO3 (); // vertical ozone column features // Card2 parasMap. put ("IHAZE", String. valueOf (ATM condientities. get (0 ). getAerosolMode (); // aerosol pattern parasMap. put ("VIS", String. valueOf (ATM condientities. get (0 ). getVis (); // meteorological line of sight // Card3 parasMap. put ("H2", String. valueOf (geoPathEntities. get (0 ). getTargetAltitude (); // The target altitude is parasMap. put ("ANGLE", String. valueOf (geoPathEntities. get (0 ). getSatZenithAngle (); // the top corner of the satellite. // Card3A1 parasMap. put ("IDAY", String. valueOf (geoPathEntities. get (0 ). getSequenceDay (); // sequential days // Card3A2 parasMap. put ("PARM1", String. valueOf (geoPathEntities. get (0 ). getObservelati (); // observes the latitude of parasMap. put ("PARM2", String. valueOf (geoPathEntities. get (0 ). getObservelong (); // observes the longitude of parasMap. put ("TIME", String. valueOf (geoPathEntities. get (0 ). getObserveTime (); // observation time parasMap. put ("V1", String. valueOf (spectralEntities. get (0 ). getStartWvl (); // start wavelength parasMap. put ("V2", String. valueOf (spectralEntities. get (0 ). getEndWvl (); // termination wavelength} public ATM module () {parasMapLast = new HashMap <String, String> (); bandInfoList = new ArrayList <> ();} public void init (String aBandInfoPath, String region, String aRefPath, String aResultPath) {bandInfoPath = aBandInfoPath; atmParasPath = region; refPath = aRefPath; resultPath = aResultPath; region ();} public void run () throws IOException {// ========================= prepare the channel and channel response information (SSR) ============================ File sensorFolder = new File (bandInfoPath ); string [] sensorBandFileName = sensorFolder. list (dir, name)-> name. endsWith ("rsp"); for (int I = 0; I <sensorBandFileName. length; ++ I) {// The number of files and the number of channel information to be prepared. String ssrFilePath = bandInfoPath + "/" + sensorBandFileName [I]; readSSRFile ssrFile = new ReadSSRFile (ssrFilePath); Double waveLenDleta = 1.0; ssrFile. formSSR (waveLenDleta); // sets the wavelength interval of the system spectrum response to 1 nm List <Double> wavelength = ssrFile. getLambda (); // obtain the wavelength column of the SSR file (after interpolation) List <Double> ssr = ssrFile. getResponse (); // obtain the system spectrum response value column corresponding to each wavelength of the SSR file (after interpolation) ssrFile. close (); Band tmpBand = new Band (); tmpBand.wav elength = wavelength; tmpBand. ssr = ssr; bandInfoList. add (tmpBand );} // ============================== run the modtran Process ===================================== final double rou1 = 0.3; // sets the reflectivity final double rou2 = 0.8 during the two running times; // Modtran processes CallModtran callModtran = new CallModtran (null, rou1, rou2, parasMap) twice ); tape7Columns tape7Cols = callModtran. getTape7Cols (); // ======================== solving the equation; solving discrete Ls and Lh; solution channel Ls, Lh ============================================ = // SolveEq solveEq = new SolveEq (tape7Cols, rou1, rou2); pattern MList = solveEq. getResults (); // calculate the discrete Ls and Lh (the background reflectivity is temporarily replaced by 0.5, to be changed to the calculated mean) GenDiscreteLsLh genDiscreteLsLh = new GenDiscreteLsLh (patequalmlist, 0.5 ); list <DiscreteLsLh> discreteLsLhsList = genDiscreteLsLh. getDiscreteLsLh (); // calculate the Ls and Lh List of each channel <BandLsLh> bandLsLh = Utility. integrate (discreteLsLhsList, bandInfoList, 1.0 ); // ====================================== calculate the reflectivity of the channel by the reflectivity of each channel ====================================== FileWriter fos = new FileWriter (". /LuminaceImageInfo "); String formatTitle =" % s \ n "; // title format String format = "% s % f \ n"; // file content format String title = String. format (formatTitle, "FILENAME", "START", "END", "CENTER"); fos. write (title); for (int bandIndex = 0; bandIndex <bandLsLh. size (); ++ bandIndex) {// number of cycles = number of channels ImagePlus refImage = new ImagePlus (refPath); refImage. getProcessor (). subtract (32768.0); ImageProcessor ip = refImage. getProcessor (). duplicate (); int h = ip. getHeight (); int w = ip. getWidth (); short [] sourcePixel = (short []) ip. getPixels (); float [] resPixel = new float [h * w]; BandLsLh bandLsLhTmp = bandLsLh. get (bandIndex); for (int I = 0; I