[GRASS-SVN] r42890 - grass/branches/develbranch_6/imagery/i.atcorr
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 25 06:16:31 EDT 2010
Author: aghisla
Date: 2010-07-25 10:16:31 +0000 (Sun, 25 Jul 2010)
New Revision: 42890
Added:
grass/branches/develbranch_6/imagery/i.atcorr/create_iwave.py
Modified:
grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp
grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.h
grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp
grass/branches/develbranch_6/imagery/i.atcorr/Iwave.h
grass/branches/develbranch_6/imagery/i.atcorr/description.html
Log:
backport of avinr and ikonos atmospheric correction from trunk
Modified: grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp 2010-07-25 10:14:38 UTC (rev 42889)
+++ grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp 2010-07-25 10:16:31 UTC (rev 42890)
@@ -363,7 +363,9 @@
case 7: /* tm ( landsat ) * enter month,day,hh.ddd,long.,lat. */
case 8: /* etm+ ( landsat7) * enter month,day,hh.ddd,long.,lat. */
case 9: /* liss ( IRS 1C) * enter month,day,hh.ddd,long.,lat. */
- case 10: /* aster * enter month,day,hh.ddd,long.,lat. */
+ case 10: /* aster * enter month,day,hh.ddd,long.,lat. */
+ case 11: /* avnir * enter month,day,hh.ddd,long.,lat. */
+ case 12: /* ikonos * enter month,day,hh.ddd,long.,lat. */
{
cin >> month;
cin >> jday;
@@ -409,7 +411,7 @@
/* ---- print geometrical conditions ---- */
void GeomCond::print()
{
- static const string etiq1[11] = {
+ static const string etiq1[13] = {
string(" user defined conditions "),
string(" meteosat observation "),
string(" goes east observation "),
@@ -420,7 +422,9 @@
string(" t.m. observation "),
string(" etm+ observation "),
string(" liss observation "),
- string(" aster observation ")
+ string(" aster observation "),
+ string(" avnir observation "),
+ string(" ikonos observation ")
};
static const string head(" geometrical conditions identity ");
Modified: grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.h 2010-07-25 10:14:38 UTC (rev 42889)
+++ grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.h 2010-07-25 10:16:31 UTC (rev 42890)
@@ -49,7 +49,11 @@
/* c */
/* 10 aster * enter month,day,hh.ddd,long.,lat.c */
/* c */
+/* 11 avnir * enter month,day,hh.ddd,long.,lat.c */
/* c */
+/* 12 ikonos * enter month,day,hh.ddd,long.,lat.c */
+/* c */
+/* c */
/* note: for hrv and tm experiments long. and lat. are the c */
/* coordinates of the scene center. c */
/* lat. must be > 0 for north lat., < 0 for south lat. c */
Modified: grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp 2010-07-25 10:14:38 UTC (rev 42889)
+++ grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp 2010-07-25 10:16:31 UTC (rev 42890)
@@ -1958,6 +1958,230 @@
}
}
+/* Following filter function created using create_iwave.py */
+
+void IWave::avnir(int iwa)
+{
+ /* "band 1" of AVNIR */
+ static const float sr1[64] = {
+ .0000, .0000, .0000, .0008, .0017, .0049, .0080,
+ .0293, .0776, .1260, .2609, .3958, .5315, .6672,
+ .7223, .7262, .7300, .7272, .7245, .7717, .8189,
+ .8815, .9068, .9322, .9496, .9669, .9708, .9747,
+ 1.0000, .9849, .9699, .9507, .9316, .9365, .9415,
+ .9849, .9600, .9351, .7552, .5754, .3911, .2068,
+ .0655, .0440, .0226, .0150, .0075, .0046, .0018,
+ .0000, .0000, .0000, .0000, .0000, .0000, .0000
+ };
+
+ /* "band 2" of AVNIR */
+ static const float sr2[56] = {
+ .0000, .0000, .0000, .0008, .0015, .0030, .0045,
+ .0202, .0470, .0739, .1358, .1977, .3205, .4433,
+ .6832, .7137, .7442, .7594, .7746, .8089, .8432,
+ .8719, .8721, .8724, .8873, .9022, .9254, .9486,
+ .9764, .9882, 1.0000, .9904, .9808, .9349, .8890,
+ .7843, .7651, .7458, .7156, .6854, .5639, .4425,
+ .1586, .0985, .0384, .0236, .0088, .0053, .0017
+ };
+
+ /* "band 3" of AVNIR */
+ static const float sr3[80] = {
+ .0000, .0000, .0000, .0000, .0000, .0000, .0000,
+ .0016, .0025, .0034, .0043, .0051, .0075, .0099,
+ .0153, .0228, .0304, .0462, .0620, .0995, .1370,
+ .2844, .3857, .4871, .5747, .6624, .7198, .7771,
+ .8021, .7991, .7960, .7989, .8017, .8312, .8606,
+ .9359, .9592, .9825, .9912, 1.0000, .9931, .9862,
+ .9275, .9046, .8818, .8607, .8395, .8344, .8293,
+ .8136, .7470, .6804, .5481, .4158, .3100, .2043,
+ .0898, .0634, .0369, .0273, .0177, .0135, .0093,
+ .0060, .0045, .0030, .0023, .0015, .0016, .0016
+ };
+
+ /* "band 4" of AVNIR */
+ static const float sr4[120] = {
+ .0000, .0000, .0000, .0000, .0000, .0000, .0000,
+ .0023, .0023, .0022, .0033, .0045, .0080, .0115,
+ .0264, .0484, .0704, .1138, .1572, .2351, .3129,
+ .5733, .7244, .8754, .9377, 1.0000, .9884, .9768,
+ .9288, .9091, .8894, .8763, .8633, .8627, .8622,
+ .8885, .9136, .9388, .9437, .9486, .9531, .9576,
+ .9247, .8969, .8691, .8467, .8242, .7893, .7545,
+ .7117, .6911, .6705, .6560, .6414, .6357, .6299,
+ .6217, .6227, .6237, .6025, .5812, .5843, .5874,
+ .5860, .5696, .5532, .5251, .4969, .4438, .3908,
+ .2475, .1906, .1338, .1033, .0727, .0543, .0359,
+ .0224, .0161, .0097, .0069, .0040, .0038, .0036,
+ .0025, .0024, .0024, .0015, .0007, .0004, .0000,
+ .0007, .0006, .0006, .0006, .0006, .0003, .0000,
+ .0000, .0000, .0000, .0000, .0000, .0000, .0000
+ };
+
+ static const float wli[4] = {0.390, 0.485, 0.545, 0.700};
+ static const float wls[4] = {0.550, 0.625, 0.745, 1.000};
+
+ ffu.wlinf = (float)wli[iwa-1];
+ ffu.wlsup = (float)wls[iwa-1];
+
+ int i;
+ for(i = 0; i < 1501; i++) ffu.s[i] = 0;
+
+ switch(iwa)
+ {
+ case 1: for(i = 0; i < 64; i++) ffu.s[56+i] = sr1[i];
+ break;
+ case 2: for(i = 0; i < 56; i++) ffu.s[94+i] = sr2[i];
+ break;
+ case 3: for(i = 0; i < 80; i++) ffu.s[118+i] = sr3[i];
+ break;
+ case 4: for(i = 0; i < 120; i++) ffu.s[180+i] = sr4[i];
+ break;
+ }
+}
+
+/* Following filter function created using create_iwave.py */
+
+void IWave::ikonos(int iwa)
+{
+
+ /* "Ikonos Green" of ikonos */
+ static const float sr1[274] = {
+ .0008, .0011, .0015, .0012, .0009, .0008, .0007,
+ .0007, .0010, .0013, .0015, .0017, .0018, .0019,
+ .0028, .0040, .0052, .0064, .0077, .0082, .0088,
+ .0119, .0147, .0175, .0262, .0350, .0602, .0854,
+ .1929, .2617, .3305, .3750, .4195, .4638, .5082,
+ .6132, .6437, .6742, .6973, .7204, .7406, .7608,
+ .7601, .7742, .7883, .8225, .8566, .8730, .8894,
+ .9436, .9718, 1.0000, .9934, .9868, .9562, .9255,
+ .7613, .6519, .5424, .4282, .3139, .2590, .2041,
+ .1519, .1188, .0856, .0644, .0432, .0371, .0310,
+ .0266, .0244, .0222, .0221, .0221, .0242, .0262,
+ .0296, .0283, .0270, .0248, .0226, .0240, .0254,
+ .0305, .0289, .0274, .0243, .0213, .0215, .0217,
+ .0296, .0319, .0342, .0306, .0271, .0233, .0195,
+ .0195, .0193, .0190, .0165, .0140, .0107, .0073,
+ .0060, .0056, .0051, .0065, .0079, .0101, .0123,
+ .0200, .0210, .0221, .0214, .0208, .0199, .0190,
+ .0155, .0126, .0097, .0083, .0068, .0059, .0049,
+ .0054, .0085, .0115, .0169, .0222, .0231, .0240,
+ .0121, .0080, .0040, .0031, .0022, .0024, .0026,
+ .0023, .0029, .0035, .0030, .0025, .0024, .0023,
+ .0040, .0038, .0036, .0032, .0027, .0025, .0024,
+ .0026, .0024, .0022, .0019, .0016, .0016, .0016,
+ .0020, .0020, .0020, .0023, .0025, .0031, .0036,
+ .0056, .0061, .0066, .0071, .0075, .0078, .0080,
+ .0095, .0089, .0083, .0085, .0088, .0090, .0093,
+ .0107, .0116, .0125, .0128, .0131, .0131, .0131,
+ .0119, .0112, .0105, .0100, .0095, .0091, .0088,
+ .0084, .0083, .0082, .0081, .0080, .0082, .0084,
+ .0081, .0081, .0080, .0080, .0080, .0074, .0069,
+ .0054, .0051, .0048, .0046, .0045, .0043, .0041,
+ .0036, .0035, .0035, .0034, .0033, .0030, .0028,
+ .0028, .0026, .0024, .0024, .0023, .0025, .0026,
+ .0026, .0026, .0026, .0021, .0016, .0018, .0019,
+ .0024
+ };
+
+ /* "Ikonos Red" of ikonos */
+ static const float sr2[274] = {
+ .0006, .0007, .0008, .0008, .0007, .0008, .0008,
+ .0006, .0007, .0008, .0007, .0006, .0008, .0009,
+ .0006, .0010, .0013, .0013, .0012, .0019, .0027,
+ .0010, .0011, .0013, .0016, .0019, .0023, .0027,
+ .0034, .0037, .0040, .0049, .0057, .0074, .0091,
+ .0113, .0113, .0113, .0122, .0130, .0151, .0172,
+ .0245, .0306, .0367, .0435, .0503, .0565, .0628,
+ .1094, .1512, .1931, .2421, .2911, .3653, .4396,
+ .6507, .7286, .8066, .8391, .8717, .8801, .8884,
+ .8898, .8824, .8749, .8635, .8521, .8722, .8923,
+ .9977, .9819, .9661, .9369, .9077, .9005, .8932,
+ .9459, .9715, .9972, .9785, .9598, .9186, .8774,
+ .7497, .6259, .5020, .3926, .2832, .2215, .1599,
+ .1068, .0947, .0825, .0732, .0640, .0557, .0474,
+ .0320, .0273, .0227, .0196, .0166, .0155, .0145,
+ .0148, .0155, .0162, .0174, .0186, .0193, .0199,
+ .0188, .0170, .0152, .0138, .0125, .0122, .0119,
+ .0109, .0122, .0135, .0150, .0165, .0174, .0183,
+ .0159, .0135, .0112, .0088, .0063, .0059, .0055,
+ .0034, .0036, .0039, .0037, .0035, .0032, .0030,
+ .0031, .0027, .0023, .0029, .0034, .0035, .0036,
+ .0053, .0059, .0065, .0068, .0072, .0080, .0089,
+ .0095, .0088, .0080, .0075, .0070, .0067, .0064,
+ .0061, .0059, .0056, .0054, .0053, .0057, .0061,
+ .0074, .0070, .0067, .0067, .0067, .0081, .0094,
+ .0128, .0135, .0143, .0151, .0159, .0165, .0171,
+ .0172, .0168, .0163, .0158, .0152, .0143, .0134,
+ .0120, .0113, .0106, .0103, .0100, .0096, .0092,
+ .0098, .0093, .0089, .0087, .0084, .0081, .0078,
+ .0075, .0072, .0070, .0064, .0059, .0056, .0054,
+ .0046, .0043, .0039, .0038, .0036, .0034, .0033,
+ .0029, .0029, .0028, .0028, .0028, .0025, .0022,
+ .0025, .0024, .0022, .0024, .0025, .0023, .0021,
+ .0017, .0019, .0021, .0021, .0020, .0021, .0022,
+ .0014
+ };
+
+ /* "Ikonos NIR" of ikonos */
+ static const float sr3[274] = {
+ .0000, .0003, .0005, .0004, .0004, .0005, .0006,
+ .0003, .0006, .0008, .0007, .0007, .0005, .0004,
+ .0015, .0018, .0020, .0025, .0030, .0033, .0035,
+ .0040, .0041, .0041, .0060, .0078, .0081, .0084,
+ .0082, .0066, .0051, .0038, .0026, .0035, .0043,
+ .0055, .0055, .0055, .0042, .0029, .0023, .0017,
+ .0015, .0026, .0036, .0040, .0043, .0034, .0025,
+ .0020, .0017, .0013, .0014, .0015, .0015, .0015,
+ .0021, .0022, .0024, .0025, .0027, .0030, .0034,
+ .0029, .0029, .0029, .0035, .0041, .0050, .0060,
+ .0072, .0083, .0093, .0093, .0093, .0090, .0087,
+ .0095, .0099, .0103, .0118, .0133, .0169, .0204,
+ .0285, .0316, .0347, .0388, .0428, .0502, .0575,
+ .0855, .1052, .1249, .1506, .1764, .2174, .2584,
+ .4188, .5285, .6381, .7213, .8045, .8414, .8784,
+ .9196, .9364, .9532, .9545, .9559, .9424, .9289,
+ .9389, .9628, .9866, .9917, .9968, .9524, .9079,
+ .7698, .6808, .5919, .5067, .4215, .3634, .3053,
+ .2262, .1923, .1583, .1315, .1046, .0860, .0674,
+ .0447, .0373, .0299, .0269, .0239, .0230, .0220,
+ .0184, .0171, .0159, .0161, .0162, .0159, .0157,
+ .0165, .0168, .0171, .0167, .0163, .0142, .0121,
+ .0091, .0079, .0068, .0065, .0062, .0059, .0056,
+ .0042, .0042, .0042, .0046, .0050, .0045, .0040,
+ .0040, .0033, .0027, .0028, .0030, .0028, .0025,
+ .0033, .0029, .0026, .0026, .0026, .0027, .0028,
+ .0027, .0028, .0028, .0027, .0026, .0026, .0026,
+ .0025, .0024, .0024, .0024, .0023, .0026, .0029,
+ .0027, .0029, .0031, .0035, .0039, .0040, .0040,
+ .0040, .0037, .0035, .0031, .0026, .0024, .0022,
+ .0016, .0015, .0014, .0014, .0013, .0013, .0014,
+ .0011, .0011, .0012, .0012, .0012, .0011, .0010,
+ .0016, .0013, .0010, .0012, .0013, .0014, .0014,
+ .0029, .0023, .0018, .0020, .0023, .0018, .0013,
+ .0009
+ };
+
+ static const float wli[3] = {0.350, 0.350, 0.350};
+ static const float wls[3] = {1.035, 1.035, 1.035};
+
+ ffu.wlinf = (float)wli[iwa-1];
+ ffu.wlsup = (float)wls[iwa-1];
+
+ int i;
+ for(i = 0; i < 1501; i++) ffu.s[i] = 0;
+
+ switch(iwa)
+ {
+ case 1: for(i = 0; i < 274; i++) ffu.s[40+i] = sr1[i];
+ break;
+ case 2: for(i = 0; i < 274; i++) ffu.s[40+i] = sr2[i];
+ break;
+ case 3: for(i = 0; i < 274; i++) ffu.s[40+i] = sr3[i];
+ break;
+ }
+}
+
float IWave::equivwl() const
{
float seb = 0;
@@ -2025,6 +2249,8 @@
else if(iwave <= 67) etmplus(iwave - 60);
else if(iwave <= 71) irs_1c_liss(iwave - 67);
else if(iwave <= 80) aster(iwave - 71);
+ else if(iwave <= 84) avnir(iwave - 80);
+ else if(iwave <= 87) ikonos(iwave - 84);
else G_warning(_("Unsupported iwave value: %d"), iwave);
}
@@ -2041,7 +2267,7 @@
/* --- spectral condition ---- */
void IWave::print()
{
- static const string nsat[82] = {
+ static const string nsat[89] = {
string(" constant "), string(" user s "),
string(" meteosat "), string(" goes east "), string(" goes west "),
string(" avhrr 1 (noaa6) "), string(" avhrr 2 (noaa6) "),
@@ -2075,7 +2301,10 @@
string(" liss 5 "),
string(" aster 1 "), string(" aster 2 "), string(" aster 3N "),
string(" aster 4 "), string(" aster 5 "), string(" aster 6 "),
- string(" aster 7 "), string(" aster 8 "), string(" aster 9 ")
+ string(" aster 7 "), string(" aster 8 "), string(" aster 9 "),
+ string(" avnir 1 "), string(" avnir 2 "), string(" avnir 3 "),
+ string(" avnir 4 "), string(" ikonos green "), string(" ikonos red "),
+ string(" ikonos NIR ")
};
Modified: grass/branches/develbranch_6/imagery/i.atcorr/Iwave.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/Iwave.h 2010-07-25 10:14:38 UTC (rev 42889)
+++ grass/branches/develbranch_6/imagery/i.atcorr/Iwave.h 2010-07-25 10:16:31 UTC (rev 42890)
@@ -102,6 +102,13 @@
c 78 7th " ( 2.200-2.393 ) c
c 79 8th " ( 2.248-2.475 ) c
c 80 9th " ( 2.295-2.538 ) c
+c 81 1st band of avnir ( 0.390-0.550 ) c
+c 82 2nd " ( 0.485-0.695 ) c
+c 83 3rd " ( 0.545-0.745 ) c
+c 84 4th " ( 0.700-0.925 ) c
+c 85 Green band of IKONOS ( 0.350-1.035 ) c
+c 86 Red " ( 0.350-1.035 ) c
+c 87 NIR " ( 0.350-1.035 ) c
c note: wl has to be in micrometer c
c**********************************************************************/
@@ -138,6 +145,8 @@
void etmplus(int iwa);
void irs_1c_liss(int iwa);
void aster(int iwa);
+ void avnir(int iwa);
+ void ikonos(int iwa);
public:
Added: grass/branches/develbranch_6/imagery/i.atcorr/create_iwave.py
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/create_iwave.py (rev 0)
+++ grass/branches/develbranch_6/imagery/i.atcorr/create_iwave.py 2010-07-25 10:16:31 UTC (rev 42890)
@@ -0,0 +1,243 @@
+#!/usr/bin/python2.6
+"""
+Created on Sat Mar 27 11:35:32 2010
+
+Program to interpolate filter function to correct
+step. Should be 2.5 nm
+Then output filter function in a format similar to
+what is needed in the Iwave.cpp file
+
+Needs numpy and scipy
+
+ at author: daniel
+contact: daniel {dot} victoria {at} gmail {dot} com
+
+usage() explains how this is supposed to work
+Basically it needs a .csv file with spectral response for each
+band in a column. First column has to be wavelength (nm)
+First line (and only first) is a header with Wl, followed by band names
+file name is used for sensor name
+
+Self though programer warning: beware of fractured python bellow
+and fractured english also :)
+"""
+import os
+import sys
+import numpy as np
+from scipy import interpolate
+
+def usage():
+ """How to use this..."""
+ print "create_iwave.py <csv file>"
+ print "Generate filter function IWave.cpp template from csv file"
+ print "csv file must have wl response for each band in each column"
+ print "first line must be a header with wl followed by band names"
+ print "following lines will be the data."
+ print "If response is null, leave empty in csv file. Ex.:"
+ print "WL(nm),band 1,band 2,band 3,band 4"
+ print "455,0.93,,,"
+ print "485,0.94,0.00,,"
+ print "545,0.00,0.87,0.00,"
+ print "Program will interpolate filter function to 2.5 nm steps"
+ print "and output a cpp template file in the IWave format"
+
+def read_input(csvfile):
+ """
+ Function to read input file
+ return number of bands and array of values for each band
+ should be a .csv file with the values
+ of the filter function for each band in the sensor
+ one column for band
+ first line must have a header with sensor band name
+ first column is wavelength
+ """
+ infile = open(csvfile, 'r')
+
+ # get number of bands and band names
+ bands = infile.readline().split(',')
+ bands.remove(bands[0])
+ bands[-1] = bands[-1].strip()
+
+ infile.close()
+
+ # create converter dictionary for import
+ # fix nodata or \n
+ conv = {}
+ for b in range(len(bands)):
+ conv[b+1] = lambda s: float(s or -99)
+
+ values = np.loadtxt(csvfile, delimiter=',', skiprows=1, converters = conv)
+
+ return (bands, values)
+
+def interpolate_band(values):
+ """
+ Receive wavelength and response for one band
+ interpolate at 2.5 nm steps
+ return interpolated filter func
+ and min, max wl values
+ values must be numpy array with 2 columns
+ """
+ # These 2 lines select the subarray
+ # remove nodata (-99) lines in values array
+ # where response is nodata?
+ w = values[:,1] >= 0
+ response = values[w]
+
+ # interpolating
+ f = interpolate.interp1d(response[:,0],response[:,1])
+
+ filter_f = f(np.arange(response[0,0], response[-1,0], 2.5))
+
+ # convert limits from nanometers to micrometers
+ lowerlimit = response[0,0]/1000
+ upperlimit = response[-1,0]/1000
+
+ return(filter_f, (lowerlimit, upperlimit))
+
+def plot_filter(values):
+ """Plot wl response values and interpolated
+ filter function. This is just for checking...
+ value is a 2 column numpy array
+ function has to be used inside Spyder python environment
+ """
+ filter_f, limits = interpolate_band(values)
+
+ # removing nodata
+ w = values[:,1] >= 0
+ response = values[w]
+
+ plot(response[:,0],response[:,1], 'ro')
+ plot(arange(limits[0], limits[1], 2.5), filter_f)
+
+ return
+
+def pretty_print(filter_f):
+ """
+ Create pretty string out of filter function
+ 8 values per line, with spaces, commas and all the rest
+ """
+ pstring = ''
+ for i in range(len(filter_f)):
+ if i%8 is 0:
+ if i is not 1:
+ # trim the trailing whitespace at the end of line
+ pstring = pstring.rstrip()
+ pstring += "\n\t\t"
+ else:
+ value_wo_leading_zero = ('%.4f' % (filter_f[i-1])).lstrip('0')
+ pstring += value_wo_leading_zero+', '
+ # trim starting \n and trailing ,
+ pstring = pstring.lstrip("\n").rstrip(", ")
+ return pstring
+
+def write_cpp(bands, values, sensor, folder):
+ """
+ from bands, values and sensor name
+ create output file in cpp style
+ needs other functions: interpolate_bands, pretty_print
+ """
+
+ # getting necessary data
+ # single or multiple bands?
+ if len(bands) == 1:
+ filter_f, limits = interpolate_band(values)
+ else:
+ filter_f = []
+ limits = []
+ for b in range(len(bands)):
+ fi, li = interpolate_band(values[:,[0,b+1]])
+ filter_f.append(fi)
+ limits.append(li)
+
+ # writing...
+ outfile = open(os.path.join(folder, sensor+"_cpp_template.txt"), 'w')
+ outfile.write('/* Following filter function created using create_iwave.py */\n\n')
+
+ if len(bands) == 1:
+ outfile.write('void IWave::%s()\n{\n\n' % (sensor.lower()))
+ else:
+ outfile.write('void IWave::%s(int iwa)\n{\n\n' % (sensor.lower()))
+
+ # single band case
+ if len(bands) == 1:
+ outfile.write(' /* %s of %s */\n' % (bands[0], sensor))
+ outfile.write(' static const float sr[%i] = {' % (len(filter_f)))
+ filter_text = pretty_print(filter_f)
+ outfile.write(filter_text)
+
+ # calculate wl slot for band start
+ # slots range from 250 to 4000 at 2.5 increments (total 1500)
+ s_start = int((limits[0]*1000 - 250)/2.5)
+
+ outfile.write('\n')
+ outfile.write(' ffu.wlinf = %.4ff;\n' % (limits[0]))
+ outfile.write(' ffu.wlsup = %.4ff;\n' % (limits[1]))
+ outfile.write(' int i = 0;\n')
+ outfile.write(' for(i = 0; i < %i; i++)\tffu.s[i] = 0;\n' % (s_start))
+ outfile.write(' for(i = 0; i < %i; i++)\tffu.s[%i+i] = sr[i];\n' % (len(filter_f), s_start))
+ outfile.write(' for(i = %i; i < 1501; i++)\tffu.s[i] = 0;\n' % (s_start + len(filter_f)))
+ outfile.write('}\n')
+
+ else: # more than 1 band
+ # writing bands
+ for b in range(len(bands)):
+ outfile.write(' /* %s of %s */\n' % (bands[b], sensor))
+ outfile.write(' static const float sr%i[%i] = {\n' % (b+1,len(filter_f[b])))
+ filter_text = pretty_print(filter_f[b])
+ outfile.write(filter_text+'\n };\n\t\n')
+
+ # writing band limits
+ for b in range(len(bands)):
+ inf = ", ".join(["%.3f" % i[0] for i in limits])
+ sup = ", ".join(["%.3f" % i[1] for i in limits])
+
+ outfile.write(' static const float wli[%i] = {%s};\n' % (len(bands), inf))
+ outfile.write(' static const float wls[%i] = {%s};\n' % (len(bands), sup))
+
+ outfile.write('\n')
+ outfile.write(' ffu.wlinf = (float)wli[iwa-1];\n')
+ outfile.write(' ffu.wlsup = (float)wls[iwa-1];\n\n')
+
+ outfile.write(' int i;\n')
+ outfile.write(' for(i = 0; i < 1501; i++) ffu.s[i] = 0;\n\n')
+
+ outfile.write(' switch(iwa)\n {\n')
+
+ # now start of case part...
+ for b in range(len(bands)):
+ s_start = int((limits[b][0]*1000 - 250)/2.5)
+ outfile.write(' case %i: for(i = 0; i < %i; i++) ffu.s[%i+i] = sr%i[i];\n' % ((b+1), len(filter_f[b]), s_start, (b+1)))
+ outfile.write(' break;\n')
+ outfile.write(' }\n}\n')
+
+ return
+
+def main():
+ """ control function """
+
+ inputfile = sys.argv[1]
+
+ # getting sensor name from full csv file name
+ sensor = os.path.splitext(os.path.basename(inputfile))[0]
+
+ print "Getting sensor name from csv file: %s" % (sensor)
+
+ # getting data from file
+ bands, values = read_input(inputfile)
+
+ # writing file in same folder of input file
+ write_cpp(bands, values, sensor, os.path.dirname(inputfile))
+
+ print "Filter function written to %s" % (sensor+"_cpp_template.txt")
+ print "Please check file for possible errors before inserting into IWave.cpp"
+ print "Don't forget to add necessary data to IWave.h"
+
+ return
+
+if __name__ == '__main__':
+ if len(sys.argv) == 1:
+ usage()
+ sys.exit()
+ else:
+ main()
Property changes on: grass/branches/develbranch_6/imagery/i.atcorr/create_iwave.py
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: grass/branches/develbranch_6/imagery/i.atcorr/description.html
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/description.html 2010-07-25 10:14:38 UTC (rev 42889)
+++ grass/branches/develbranch_6/imagery/i.atcorr/description.html 2010-07-25 10:16:31 UTC (rev 42890)
@@ -139,6 +139,19 @@
<td><b>aster</b></td>
<td>enter month,day,hh.ddd,long.,lat. *</td>
</tr>
+
+<tr>
+<td>11</td>
+<td><b>avnir</b></td>
+<td>enter month,day,hh.ddd,long.,lat. *</td>
+</tr>
+
+<tr>
+<td>12</td>
+<td><b>ikonos</b></td>
+<td>enter month,day,hh.ddd,long.,lat. *</td>
+</tr>
+
</table>
<blockquote>
@@ -505,6 +518,16 @@
<tr><td>78</td><td>aster band 7 (2.200-2.393)</td></tr>
<tr><td>79</td><td>aster band 8 (2.248-2.475)</td></tr>
<tr><td>80</td><td>aster band 9 (2.295-2.538)</td></tr>
+
+<tr><td>81</td><td><b>avnir</b> band 1 (0.390-0.550)</td></tr>
+<tr><td>82</td><td>avnir band 2 (0.485-0.695)</td></tr>
+<tr><td>83</td><td>avnir band 3 (0.545-0.745)</td></tr>
+<tr><td>84</td><td>avnir band 4 (0.700-0.925)</td></tr>
+
+<tr><td>85</td><td><b>ikonos</b> Green band (0.350-1.035)</td></tr>
+<tr><td>86</td><td>ikonos Red band (0.350-1.035)</td></tr>
+<tr><td>87</td><td>ikonos NIR band (0.350-1.035)</td></tr>
+
</table>
<h2>EXAMPLES</h2>
More information about the grass-commit
mailing list