~ubuntu-branches/ubuntu/saucy/doris/saucy

« back to all changes in this revision

Viewing changes to .pc/spelling.patch/src/readinput.cc

  • Committer: Package Import Robot
  • Author(s): Antonio Valentino
  • Date: 2012-12-19 19:29:21 UTC
  • Revision ID: package-import@ubuntu.com-20121219192921-wzijb38bxndmwl3m
Tags: 4.06~beta2+dfsg-1
Initial release (Closes: #696520)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1999-2009 Delft University of Technology, The Netherlands
 
3
 *
 
4
 * This file is part of Doris, the Delft o-o radar interferometric software.
 
5
 *
 
6
 * Doris program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * Doris is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 *
 
20
 *
 
21
 */
 
22
/****************************************************************
 
23
 * $Source: /users/kampes/DEVELOP/DORIS/doris/src/RCS/readinput.cc,v $
 
24
 * $Revision: 3.36 $
 
25
 * $Date: 2009/01/09 11:09:20 $
 
26
 * $Author: TUDelft $
 
27
 *
 
28
 * implementation of readinput.
 
29
 ****************************************************************/
 
30
 
 
31
#include "matrixbk.hh"
 
32
#include "constants.hh"         // global constants
 
33
#include "ioroutines.hh"        // ?
 
34
#include "utilities.hh"         // ispower2
 
35
#include "exceptions.hh"        // my exceptions class
 
36
 
 
37
#include <fstream>              // for file streams
 
38
#include <strstream>            // for file streams
 
39
#include <iomanip>              // for setprecision etc.
 
40
#include <cstring>              // for strcmp etc.
 
41
#include <cstdlib>              // exit, atoi
 
42
#include <cctype>               // isspace
 
43
 
 
44
 
 
45
 
 
46
// ______ displevel used in ioroutines.h, changed here ______
 
47
char WARNS[6][ONE27];           // remember 6 last warnings in WARNS
 
48
int32   beeplevel=1;            // global variable for beeping.
 
49
                                // 0:  nobeep; BEEP OFF
 
50
                                // -1: beep on error exit ; BEEP ERROR
 
51
                                // 1:  beep on error, warnings; BEEP WARNING
 
52
                                // 2:  beep on error, warnings, progress;
 
53
                                //     BEEP PROGRESS, BEEP [ON]
 
54
int32   displevel=30000;        // controls level of screen output
 
55
                                // -100 only errors
 
56
                                // 0:     warnings and errors
 
57
                                // 10000: progress, warn and err
 
58
                                // 20000: info, pro, warn and err
 
59
                                // 30000: debug, info, pro, warn, err
 
60
 
 
61
 
 
62
// ______ Checks input prototypes (see below in this file) ______
 
63
void checkgeneral     (input_gen               &generalinput, const int16 onlyprocess);
 
64
void checkreadfiles   (const input_readfiles   &readfilesinput, const int16 id);
 
65
void checkcrop        (const input_crop         &cropinput, const int16 id);
 
66
//____RaffaeleNutricato START MODIFICATION SECTION 1
 
67
void checkoversample  (const input_oversample  &oversampleinput, const int16 id);
 
68
//____RaffaeleNutricato END MODIFICATION SECTION 1
 
69
void checkporbits     (const input_pr_orbits   &porbitsinput, const int16 id);
 
70
void checksimamp      (const input_simamp      &simampinput);        //[MA] ?nec. id check?
 
71
void checkmtiming     (const input_mtiming     &mtiminginput);    //[MA] ?nec. id check?
 
72
void checkslant2h     (const input_slant2h     &slant2hinput);
 
73
void checkunwrap      (const input_unwrap      &unwrapinput);
 
74
void checkgeocode     (const input_geocode     &geocodeinput);
 
75
void checkcoarsecorr  (const input_coarsecorr  &coarsecorrinput);
 
76
void checkfine        (const input_fine        &fineinput);
 
77
void checkreltiming   (const input_reltiming   &reltiminginput); //[FvL]
 
78
void checkdemassist   (const input_demassist   &demassistinput); //[FvL]
 
79
void checkcoregpm     (const input_coregpm     &coregpminput);
 
80
void checkcomprefpha  (const input_comprefpha  &comprefphainput);
 
81
void checksubtrrefpha (const input_subtrrefpha &subtrrefphainput);
 
82
void checkresample    (const input_resample    &resampleinput);
 
83
void checkinterfero   (const input_interfero   &interferoinput);
 
84
void checkcoherence   (const input_coherence   &coherenceinput);
 
85
void checkcomprefdem  (const input_comprefdem  &comprefdeminput);
 
86
void checksubtrrefdem (const input_subtrrefdem &subtrrefdeminput);
 
87
void checkfiltrange   (const input_filtrange   &filtrangeinput);
 
88
void checkdinsar      (const input_dinsar      &dinsarinput);
 
89
void checkfiltphase   (const input_filtphase   &filtphaseinput);
 
90
void checkfiltazi     (const input_filtazi     &filtaziinput, const int16 id);
 
91
 
 
92
/****************************************************************
 
93
 *    writearg                                                  *
 
94
 * echo arg to screen if debug defined                          *
 
95
 #%// BK 13-Jul-2000                                            *
 
96
 ****************************************************************/
 
97
template <class Type>
 
98
void writearg(const Type argument)
 
99
  {
 
100
  TRACE_FUNCTION("writearg");
 
101
  DEBUG << "Read argument: " << argument;
 
102
  DEBUG.print();
 
103
  } // END writearg
 
104
 
 
105
 
 
106
 
 
107
/****************************************************************
 
108
 *    readinput                                                 *
 
109
 *                                                              *
 
110
 * Read and interpret                                           *
 
111
 * "inputoptionsfile" (file in variable: logfile).              *
 
112
 * Write to logfile (via "scratchreadinput")                    *
 
113
 * mandatory input is checked on presence by checksums (cs).    *
 
114
 * If there are more methods, process card switches default     *
 
115
 *  methodselector (if present) is used later to correct        *
 
116
 *  see for example unwrap methodeselector                      *
 
117
 * linecounter only used in case of errors                      *
 
118
 *                                                              *
 
119
 * input:                                                       *
 
120
 *  - struct: general input options                             *
 
121
 *  - struct: master readfiles input options                    *
 
122
 *  - struct: slave readfiles input options                     *
 
123
 *  - struct: master crop input options                         *
 
124
 *  - struct: slave crop input options                          *
 
125
 *  - ...                                                       *
 
126
 * output:                                                      *
 
127
 *  - (updated input structs)                                   *
 
128
 *  - (file copy of input)                                      *
 
129
 *                                                              *
 
130
 *    Bert Kampes,      11-Dec-1998                             *
 
131
 *    Mahmut Arikan,    09-Jan-2009 (code to fix linecnt bug    *
 
132
 *    G.J. van Zwieten, 09-Jan-2009  and line extend         )  *
 
133
 *    Mahmut Arikan,    29-Aug-2010 Fix: Read only those prms   *
 
134
 *                                  for processing              *
 
135
 ****************************************************************/
 
136
void readinput(
 
137
        input_gen         &generalinput, 
 
138
        input_ell         &ellipsinput,
 
139
        input_pr_orbits   &porbitsinput,
 
140
        input_readfiles   &m_readfilesinput,
 
141
        input_morbits     &morbitsinputmaster, // [HB]
 
142
        input_crop         &m_cropinput,
 
143
//____RaffaeleNutricato START MODIFICATION SECTION 2
 
144
        input_oversample  &m_oversample, 
 
145
        input_simamp      &simampinput,                   // master simamp [FvL],[MA]
 
146
        input_mtiming     &mtiminginput,                  // mtiming correl [MA]
 
147
//____RaffaeleNutricato END MODIFICATION SECTION 2
 
148
        input_readfiles   &s_readfilesinput,
 
149
        input_morbits     &morbitsinputslave,  // [HB]
 
150
        input_crop         &s_cropinput,
 
151
//____RaffaeleNutricato START MODIFICATION SECTION 3
 
152
        input_oversample  &s_oversample, 
 
153
//____RaffaeleNutricato END MODIFICATION SECTION 3
 
154
        input_filtazi     &filtaziinput,
 
155
        input_coarsecorr  &coarsecorrinput,
 
156
        input_fine        &fineinput,
 
157
        input_reltiming   &reltiminginput, //[FvL]
 
158
        input_demassist   &demassistinput, //[FvL]
 
159
        input_coregpm     &coregpminput,
 
160
        input_resample    &resampleinput,
 
161
        input_filtrange   &filtrangeinput,
 
162
        input_interfero   &interferoinput,
 
163
        input_coherence   &coherenceinput,
 
164
        input_comprefpha  &comprefphainput,
 
165
        input_subtrrefpha &subtrrefphainput,
 
166
        input_comprefdem  &comprefdeminput,
 
167
        input_subtrrefdem &subtrrefdeminput,
 
168
        input_filtphase   &filtphaseinput,
 
169
        input_dinsar      &dinsarinput,
 
170
        input_unwrap      &unwrapinput,
 
171
        input_estorbits   &estorbitsinput,   // [HB]
 
172
        input_slant2h     &slant2hinput,
 
173
        input_geocode     &geocodeinput) 
 
174
  {
 
175
  //TRACE_FUNCTION("readinput (BK 11-Dec-1998)");
 
176
  TRACE_FUNCTION("readinput rev.5 (TUDelft 29-Aug-2010)");
 
177
 
 
178
  // ______ Set ids ______
 
179
  m_readfilesinput.fileid = MASTERID;
 
180
  m_cropinput.fileid      = MASTERID;
 
181
  s_readfilesinput.fileid = SLAVEID;
 
182
  s_cropinput.fileid      = SLAVEID;
 
183
 
 
184
  // ______ Misuse generalinput.logfile to store name: open file here! ______
 
185
  //ifstream optionsfile(generalinput.logfile, ios::in | ios::nocreate);
 
186
  ifstream optionsfile(generalinput.logfile, ios::in);
 
187
  bk_assert(optionsfile,generalinput.logfile,__FILE__,__LINE__);
 
188
  string inputoptionsfile = generalinput.logfile;   // [MA] keep input filename
 
189
                                                    // later variable is updated
 
190
                                                    // as logfile name.
 
191
 
 
192
  int16                 onlyprocess     = -1;        // flag for ONLYPROCESS card
 
193
  int16                 linecnt         =  0;        // counter
 
194
  const int16           BASE10          = 10;        // [MA] base 10 defined for strtol
 
195
  //char                  keyword[EIGHTY];
 
196
  //char                  filename[4*ONE27];            // string for filenames // [MA] changed EIGHTY --> 2*ONE27, due to comments line gets longer
 
197
  char                  eachline[4*ONE27];           // assuming maximum char lenght of the line is 4*ONE27. It should be sufficient.
 
198
 
 
199
  // ______ Check (multiple) occurence of cards ______
 
200
  bool                  priorscreen     = false;     // no screen card present
 
201
  bool                  priormemory     = false;     // check if present for info
 
202
  bool                  priorbatch      = false;     // check if present for info
 
203
  bool                  prioroverwrite  = false;     // check if present for info
 
204
  bool                  priorlistinput  = false;     // check if present for info
 
205
  bool                  priorrs_fileout = false;     // 
 
206
 
 
207
 
 
208
// ====== Initialization, defaults ======
 
209
  input_ell             WGS84;
 
210
  bool                  listinput  = true;      // default copy input to log
 
211
  bool                  ellipsoid  = false;     // set default if no card present
 
212
  ellipsinput                   = WGS84;        // default
 
213
 
 
214
  register int32 i;
 
215
  for (i=0; i<NUMPROCESSES; i++)
 
216
    generalinput.process[i] = 0;                         // default no processing step
 
217
  generalinput.interactive      = true;                 // default interactive mode
 
218
  generalinput.overwrit         = false;                // default no overwriting
 
219
  generalinput.memory           = real8(MEMORY_DEF);           // default memory (500MB), see constants.hh
 
220
  strcpy(generalinput.logfile,    "log.out");           // default logfile
 
221
  strcpy(generalinput.m_resfile,  "master_result.out"); // default resultfile
 
222
  strcpy(generalinput.s_resfile,  "slave_result.out");  // default resultfile
 
223
  strcpy(generalinput.i_resfile,  "interferogram.out"); // default interf_out
 
224
  generalinput.orb_interp       = ORB_DEFAULT;          // default polyfit
 
225
  generalinput.dumpbaselineL    = 0;                    // default no dump
 
226
  generalinput.dumpbaselineP    = 0;                    // default no dump
 
227
  generalinput.preview          = 0;                    // default no preview
 
228
  generalinput.terrain_height   = 0.0;                  // above ellipsoid
 
229
  generalinput.tiepoint.x       = 0.0;                  // default none
 
230
  generalinput.tiepoint.y       = 0.0;                  // default none
 
231
  generalinput.tiepoint.z       = 0.0;                  // default none
 
232
 
 
233
  //m_readfilesinput.method     = readfiles_ers;        // default
 
234
  m_readfilesinput.sensor_id    = SLC_ERS;              // default
 
235
  setunspecified(m_readfilesinput.volfile);             // check later, then set default
 
236
  setunspecified(m_readfilesinput.leaderfile);          // check later, then set default
 
237
  setunspecified(m_readfilesinput.nullfile);            // check later, then set default
 
238
  setunspecified(m_readfilesinput.datfile);             // check later, then set default
 
239
  m_readfilesinput.rg_timing_error = 0.0;               // default
 
240
  m_readfilesinput.az_timing_error = 0.0;               // default
 
241
  //s_readfilesinput.sensor_id          = readfiles_ers;        // default
 
242
  s_readfilesinput.sensor_id    = SLC_ERS;              // default
 
243
  setunspecified(s_readfilesinput.volfile);             // check later, then set default
 
244
  setunspecified(s_readfilesinput.leaderfile);          // check later, then set default
 
245
  setunspecified(s_readfilesinput.nullfile);            // check later, then set default
 
246
  setunspecified(s_readfilesinput.datfile);             // check later, then set default
 
247
  s_readfilesinput.rg_timing_error = 0.0;               // default
 
248
  s_readfilesinput.az_timing_error = 0.0;               // default
 
249
 
 
250
  setunspecified(porbitsinput.m_orbdir);                // check later, then set default
 
251
  setunspecified(porbitsinput.s_orbdir);                // check later, then set default
 
252
  porbitsinput.timeinterval     = 1;                    // default time interval
 
253
  porbitsinput.timebefore       = 4*porbitsinput.timeinterval;   // default 4 extra datapoints
 
254
  porbitsinput.dumpmasterorbit  = -1.;                  // default no dump
 
255
  porbitsinput.dumpslaveorbit   = -1.;                  // default no dump
 
256
 
 
257
  strcpy(m_cropinput.idcrop,"master step01");           // default identifier
 
258
  strcpy(s_cropinput.idcrop,"slave step01");            // default identifier
 
259
  strcpy(m_cropinput.fileout1,"master.raw");            // default output filename
 
260
  strcpy(s_cropinput.fileout1,"slave.raw");             // default output filename
 
261
  m_cropinput.dbow.linelo       = 0;                    // min. line coord. initialization
 
262
  m_cropinput.dbow.linehi       = 0;                    // max. line coord. initialization
 
263
  m_cropinput.dbow.pixlo        = 0;                    // min. pixel coord. initialization
 
264
  m_cropinput.dbow.pixhi        = 0;                    // max. pixel coord. initialization
 
265
  s_cropinput.dbow.linelo       = 0;                    // min. line coord. initialization
 
266
  s_cropinput.dbow.linehi       = 0;                    // max. line coord. initialization
 
267
  s_cropinput.dbow.pixlo        = 0;                    // min. pixel coord. initialization
 
268
  s_cropinput.dbow.pixhi        = 0;                    // max. pixel coord. initialization
 
269
  m_cropinput.dbow_geo.linelo   = 0;                    // min. line coord. initialization
 
270
  m_cropinput.dbow_geo.linehi   = 0;                    // max. line coord. initialization
 
271
  m_cropinput.dbow_geo.pixlo    = 0;                    // min. pixel coord. initialization
 
272
  m_cropinput.dbow_geo.pixhi    = 0;                    // max. pixel coord. initialization
 
273
  s_cropinput.dbow_geo.linelo   = 0;                    // min. line coord. initialization
 
274
  s_cropinput.dbow_geo.linehi   = 0;                    // max. line coord. initialization
 
275
  s_cropinput.dbow_geo.pixlo    = 0;                    // min. pixel coord. initialization
 
276
  s_cropinput.dbow_geo.pixhi    = 0;                    // max. pixel coord. initialization
 
277
 
 
278
//____RaffaeleNutricato START MODIFICATION SECTION 4
 
279
  m_oversample.OsrRange          = 1;                    // Default for oversampling ratio in range.
 
280
  m_oversample.OsrAzimuth        = 1;                    // Default for oversampling ratio in azimuth.
 
281
  m_oversample.FilterSize        = 16;                   // Default for length of the interpolation kernel in range. 
 
282
  m_oversample.oformatflag       = FORMATCI2;            // Default for output format.
 
283
  strcpy(m_oversample.fileoutovs,"master_ovs.raw");      // Default output filename.
 
284
  s_oversample.OsrRange          = 1;                    // Default for oversampling ratio in range.
 
285
  s_oversample.OsrAzimuth        = 1;                    // Default for oversampling ratio in azimuth.
 
286
  s_oversample.FilterSize        = 16;                   // Default for length of the interpolation kernel in range. 
 
287
  s_oversample.oformatflag       = FORMATCI2;            // Default for output format.
 
288
  strcpy(s_oversample.fileoutovs,"slave_ovs.raw");       // Default output filename.
 
289
//____RaffaeleNutricato END MODIFICATION SECTION 4
 
290
 
 
291
  //____ added by MA ____
 
292
 
 
293
  setunspecified(simampinput.firefdem);                                // check later, mandatory
 
294
  //setunspecified(simampinput.fodemi);                                // check later, then set default
 
295
  setunspecified(simampinput.fodemlp);                           // check later, then set default  // MA SPT
 
296
  setunspecified(simampinput.fothetalp);                                // check later, then set default  // MA SPT
 
297
  strcpy(simampinput.fodem,"demcrop_sam.raw");                         // default name
 
298
  setunspecified(simampinput.fosimamp);                                // check later, then set default
 
299
  simampinput.iformatflag     =  FORMATI2;                             // default gtopo30
 
300
  simampinput.demrows         =  6000;                                 // default gtopo30
 
301
  simampinput.demcols         =  4800;                                 // default gtopo30
 
302
  simampinput.demnodata       = -9999;                                 // default gtopo30
 
303
  simampinput.demdeltalat     = deg2rad(0.00833333333333333333);       // default gtopo30
 
304
  simampinput.demdeltalon     = deg2rad(0.00833333333333333333);       // default gtopo30
 
305
  simampinput.demlatleftupper = deg2rad(89.995833333333333333);        // w020n90.DEM
 
306
  simampinput.demlonleftupper = deg2rad(-19.995833333333333333);       // w020n90.DEM
 
307
  strcpy(simampinput.fosimamp,"master.sam");                           // default name
 
308
 
 
309
 
 
310
  const int32 def_mte_nwin   = 16;                                      // default #windows           
 
311
  setunspecified(mtiminginput.ifpositions);                             // check later, then set default
 
312
  mtiminginput.MasksizeL     = 256;                                     // default correlation size
 
313
  //mtiminginput.MasksizeP     = mtiminginput.MasksizeL;                // default correlation size
 
314
  mtiminginput.MasksizeP     = 128;                                     // default correlation size
 
315
  mtiminginput.AccL          = 32;                                      // default searching limit
 
316
  mtiminginput.AccP          = mtiminginput.AccL;                       // default searching limit
 
317
  mtiminginput.initoffsetL   = 0;                                       // default initial offset
 
318
  mtiminginput.initoffsetP   = 0;                                       // default initial offset
 
319
 
 
320
  // ____ end added by MA ____
 
321
 
 
322
  // ____ start added by HB ____
 
323
  morbitsinputmaster.coeff        = matrix<real8>(10,2);  // 
 
324
  morbitsinputmaster.coeff        = 0;                    // default: no modification
 
325
  setunspecified(morbitsinputmaster.reforbitfile);        //
 
326
  morbitsinputslave.coeff         = matrix<real8>(10,2);  // 
 
327
  morbitsinputslave.coeff         = 0;                    // default: no modification
 
328
  setunspecified(morbitsinputslave.reforbitfile);         //
 
329
  // ____ end added by HB ____
 
330
 
 
331
  filtaziinput.oformatflag      = FORMATCR4;            // default
 
332
  filtaziinput.fftlength        = 1024;                 // default
 
333
  filtaziinput.overlap          = -1;                   // default to fftlength/8
 
334
  filtaziinput.hammingalpha     = 0.75;                 // default (slc)
 
335
  strcpy(filtaziinput.fomaster,"master.afilter");       // default
 
336
  strcpy(filtaziinput.foslave,"slave.afilter");         // default
 
337
 
 
338
  const int32 def_cc_nwin       = 11;                   // default #windows
 
339
  setunspecified(coarsecorrinput.ifpositions);          // check later, then set default
 
340
  coarsecorrinput.MasksizeL     = 64;                   // default correlation size
 
341
  coarsecorrinput.MasksizeP     = coarsecorrinput.MasksizeL;// default correlation size
 
342
  coarsecorrinput.AccL          = 8;                    // default searching limit
 
343
  coarsecorrinput.AccP          = coarsecorrinput.AccL; // default searching limit
 
344
  coarsecorrinput.initoffsetL   = 0;                    // default initial offset
 
345
  coarsecorrinput.initoffsetP   = 0;                    // default initial offset
 
346
 
 
347
  setunspecified(fineinput.ifpositions);                // check later, then set default
 
348
  const int32 def_fc_nwin       = 601;                  // default #windows
 
349
  fineinput.MasksizeL           = 64;                   // default correlation size
 
350
  fineinput.MasksizeP           = fineinput.MasksizeL;  // default correlation size
 
351
  fineinput.AccL                = 8;                    // default searching limit
 
352
  fineinput.AccP                = fineinput.AccL;       // default searching limit
 
353
  fineinput.initoffsetL         = 0;                    // default initial offset
 
354
  fineinput.initoffsetP         = 0;                    // default initial offset
 
355
  fineinput.osfactor            = 32;                   // default oversampling factor
 
356
  fineinput.plotoffsets         = false;                // default no plotting
 
357
  fineinput.plotmagbg           = false;                // default no plotting
 
358
  fineinput.plotthreshold       = 0.3;                  // default no plotting
 
359
 
 
360
  //____ added by FvL ____
 
361
  reltiminginput.threshold         = 0.4;               // default threshold data
 
362
  reltiminginput.maxiter           = 10000;             // default max. 10000 outliers removed
 
363
  reltiminginput.k_alpha           = 1.97;              // critical value for outliers
 
364
 
 
365
  setunspecified(demassistinput.firefdem);              // check later, mandatory
 
366
  setunspecified(demassistinput.fodemi);                // check later, then set default
 
367
  setunspecified(demassistinput.forefdemhei);           // check later, then set default
 
368
  strcpy(demassistinput.fodem,"demcrop.raw");           // default name
 
369
  demassistinput.iformatflag   = FORMATI2;              // default gtopo30
 
370
  demassistinput.demrows       = 6000;                  // default gtopo30
 
371
  demassistinput.demcols       = 4800;                  // default gtopo30
 
372
  demassistinput.demnodata     = -9999;                 // default gtopo30
 
373
  demassistinput.demdeltalat   = deg2rad(0.00833333333333333333);// default gtopo30
 
374
  demassistinput.demdeltalon   = deg2rad(0.00833333333333333333);// default gtopo30
 
375
  demassistinput.demlatleftupper = deg2rad(89.995833333333333333);      // w020n90.DEM
 
376
  demassistinput.demlonleftupper = deg2rad(-19.995833333333333333);// w020n90.DEM
 
377
  // ____ end added by FvL ____
 
378
 
 
379
  coregpminput.threshold        = 0.2;                  // default threshold data
 
380
  coregpminput.degree           = 1;                    // default degree polynomial
 
381
  coregpminput.weightflag       = 0;                    // default no weighting of data
 
382
  coregpminput.maxiter          = 10000;                // default max. 10000 outliers removed, changed by [FvL]
 
383
  coregpminput.k_alpha          = 1.97;                 // critical value for outliers
 
384
  coregpminput.dumpmodel        = false;                // default no files
 
385
  coregpminput.plot             = false;                // default no plots
 
386
  coregpminput.plotmagbg        = false;                // default no plots
 
387
 
 
388
  filtrangeinput.method         = rf_adaptive;          // default
 
389
  filtrangeinput.terrainslope   = 0.0;                  // default porbits
 
390
  filtrangeinput.fftlength      = -999;                 // set default later
 
391
  filtrangeinput.overlap        = 0;                    // default no overlap
 
392
  filtrangeinput.nlmean         = 15;                   // default
 
393
  filtrangeinput.hammingalpha   = 0.75;                 // default
 
394
  filtrangeinput.SNRthreshold   = 5.0;                  // default
 
395
  filtrangeinput.oversample     = 2;                    // default
 
396
  filtrangeinput.doweightcorrel = false;                // default
 
397
  strcpy(filtrangeinput.fomaster,"master.rfilter");     // default
 
398
  strcpy(filtrangeinput.foslave,"slave.rfilter");       // default
 
399
  filtrangeinput.oformatflag    = FORMATCR4;            // default
 
400
 
 
401
  setunspecified(comprefphainput.ifpositions);          // check later, then set default
 
402
  const int32 def_fe_Npoints    = 501;                  // default
 
403
  const int32 def_fe_degree     = 5;                    // default
 
404
 
 
405
  strcpy(resampleinput.fileout,"s_resampled.raw");      // default
 
406
  resampleinput.oformatflag     = FORMATCR4;            // default
 
407
  resampleinput.dbow.linelo     = 0;                    // min. line coord. initialization
 
408
  resampleinput.dbow.linehi     = 0;                    // max. line coord. initialization
 
409
  resampleinput.dbow.pixlo      = 0;                    // min. pixel coord. initialization
 
410
  resampleinput.dbow.pixhi      = 0;                    // max. pixel coord. initialization
 
411
  resampleinput.dbow_geo.linelo = 0;                    // min. line coord. initialization
 
412
  resampleinput.dbow_geo.linehi = 0;                    // max. line coord. initialization
 
413
  resampleinput.dbow_geo.pixlo  = 0;                    // min. pixel coord. initialization
 
414
  resampleinput.dbow_geo.pixhi  = 0;                    // max. pixel coord. initialization
 
415
  resampleinput.shiftazi        = true;                 // default apply shift
 
416
 
 
417
  interferoinput.method         = int_oldmethod;        // default method
 
418
  setunspecified(interferoinput.focint);                // check later, then set default
 
419
  setunspecified(interferoinput.foint);                 // use later if specified
 
420
  //setunspecified(interferoinput.foflatearth);         // check later, then set default
 
421
  interferoinput.multilookL     = 5;                    // default multilookfactor
 
422
  interferoinput.multilookP     = 1;                    // default multilookfactor
 
423
 
 
424
  coherenceinput.method         = coh_oldmethod;        // default method
 
425
  setunspecified(coherenceinput.focoh);                 // check later, then set default
 
426
  setunspecified(coherenceinput.foccoh);                // check later, then set default
 
427
  coherenceinput.multilookL     = 10;                   // default multilookfactor
 
428
  coherenceinput.multilookP     = 2;                    // default multilookfactor
 
429
  coherenceinput.cohsizeL       = coherenceinput.multilookL;    // default windowsize. 
 
430
  coherenceinput.cohsizeP       = coherenceinput.multilookP;    // default windowsize. 
 
431
 
 
432
  subtrrefphainput.method       = srp_polynomial;       // default method
 
433
  strcpy(subtrrefphainput.forefpha, "refphase.raw");    // default name
 
434
  strcpy(subtrrefphainput.focint,"cint.minrefpha.raw");// default
 
435
  subtrrefphainput.multilookL   = 1;                    // default multilookfactor
 
436
  subtrrefphainput.multilookP   = 1;                    // default multilookfactor
 
437
  subtrrefphainput.dumponlyrefpha  = false;             // default not
 
438
  //_____ added by FvL
 
439
  setunspecified(subtrrefphainput.foh2ph);              // check later, then set default
 
440
  // ____ end added by FvL
 
441
 
 
442
  filtphaseinput.method         = fp_goldstein;         // default method
 
443
  filtphaseinput.alpha          = 0.2;                  // default
 
444
  // ______ 32 blocks default for goldstein, kernel as large as possible, ______
 
445
  // ______ 2Dkernel then specify ______
 
446
  filtphaseinput.blocksize      = 32;                   // default
 
447
  filtphaseinput.overlap        = 3;                    // default
 
448
  // set default later with alpha in name
 
449
  setunspecified(filtphaseinput.fofiltphase);           // check later, then set default
 
450
  setunspecified(filtphaseinput.fifiltphase);           // if specified, use it
 
451
  setunspecified(filtphaseinput.fikernel2d);            // if specified, use it
 
452
  filtphaseinput.finumlines     = 0;                    // numlines.
 
453
 
 
454
  strcpy(dinsarinput.fodinsar,"differentialinterf.raw");// default
 
455
  setunspecified(dinsarinput.foscaleduint);             // default no output
 
456
  // ______ set mastertopo file to same as master resfile if not specified ______
 
457
  setunspecified(dinsarinput.topomasterresfile);        // if specified, use 4 pass
 
458
  setunspecified(dinsarinput.toposlaveresfile);         // check later, mandatory
 
459
  setunspecified(dinsarinput.topointresfile);           // check later, mandatory
 
460
 
 
461
  setunspecified(comprefdeminput.firefdem);             // check later, mandatory
 
462
  setunspecified(comprefdeminput.fodemi);               // check later, then set default
 
463
  //_____ added by FvL
 
464
  setunspecified(comprefdeminput.foh2ph);               // check later, then set default
 
465
  // ____ end added by FvL
 
466
  setunspecified(comprefdeminput.forefdemhei);          // check later, then set default
 
467
  strcpy(comprefdeminput.forefdem,"refdem.raw");        // default name
 
468
  strcpy(comprefdeminput.fodem,"demcrop.raw");          // default name [FvL]
 
469
  comprefdeminput.iformatflag   = FORMATI2;             // default gtopo30
 
470
//  comprefdeminput.method        = crd_trilinear;      // default method
 
471
//  comprefdeminput.extradense    = 0.5;                        // default (now interpolated in l,p)
 
472
  comprefdeminput.demrows       = 6000;                 // default gtopo30
 
473
  comprefdeminput.demcols       = 4800;                 // default gtopo30
 
474
  comprefdeminput.demnodata     = -9999;                // default gtopo30
 
475
  comprefdeminput.demdeltalat   = deg2rad(0.00833333333333333333);// default gtopo30
 
476
  comprefdeminput.demdeltalon   = deg2rad(0.00833333333333333333);// default gtopo30
 
477
  comprefdeminput.demlatleftupper = deg2rad(89.995833333333333333);     // w020n90.DEM
 
478
  comprefdeminput.demlonleftupper = deg2rad(-19.995833333333333333);// w020n90.DEM
 
479
 
 
480
  strcpy(subtrrefdeminput.focint,"cint.minrefdem.raw"); // default name
 
481
  subtrrefdeminput.offsetL      = 0;                    // default no offset
 
482
  subtrrefdeminput.offsetP      = 0;                    // default no offset
 
483
 
 
484
  strcpy(unwrapinput.fouint,"unwrapped_interferogram.raw");     // default name
 
485
  strcpy(unwrapinput.foregions,"regions_unwrapped.raw");        // default name
 
486
  setunspecified(unwrapinput.seedfile);                 // check later, then set default
 
487
  unwrapinput.deltaLseed        = 100;                  // default 100 pixels;
 
488
  unwrapinput.deltaPseed        = unwrapinput.deltaLseed;       // default 100 pixels;
 
489
  setunspecified(unwrapinput.snaphu_log);// " "
 
490
  setunspecified(unwrapinput.snaphu_coh);// " "
 
491
  strcpy(unwrapinput.snaphu_mode,"DEFO");               // default to DEFO from TOPO
 
492
  strcpy(unwrapinput.snaphu_init,"MST");                // default method
 
493
  strcpy(unwrapinput.snaphu_verbose,"TRUE");            // default verbose
 
494
  unwrapinput.oformatflag       = FORMATR4;             // default to
 
495
                                                        // REAL4 from FORMATHGT
 
496
 
 
497
  // block for Tile.CONTROL: only for SNAPHU; defaults for single CPU
 
498
  unwrapinput.ntilerow          = 1; // number of tiles in range
 
499
  unwrapinput.ntilecol          = 1; // number of tiles in azimuth
 
500
  unwrapinput.rowovrlp          = 0; // overlap between tiles in rng
 
501
  unwrapinput.colovrlp          = 0; // overlap between tiles in az
 
502
  unwrapinput.nproc             = 1; // no.cpus or nodes on load
 
503
                                     // balancing cluster
 
504
  unwrapinput.tilecostthresh   = 500; // cost threshold boundaries of reliable regions
 
505
 
 
506
 
 
507
  slant2hinput.Npoints          = 200;                  // default 100 pixels;
 
508
  slant2hinput.degree1d         = 2;                    // default 2 
 
509
  slant2hinput.degree2d         = 5;                    // default 5
 
510
  slant2hinput.Nheights         = slant2hinput.degree1d+1;// minimum
 
511
  strcpy(slant2hinput.fohei,"hei.raw");                 // default
 
512
  strcpy(slant2hinput.fophi,"phi.raw");                 // default
 
513
  strcpy(slant2hinput.folam,"lam.raw");                 // default
 
514
 
 
515
  strcpy(geocodeinput.fophi,"geo_phi.raw");             // default name
 
516
  strcpy(geocodeinput.folam,"geo_lambda.raw");          // default name
 
517
 
 
518
  // ____ start added by HB ____
 
519
  estorbitsinput.method          = eo_lsq;               // default: least squares method
 
520
  setunspecified(estorbitsinput.fiheightmap);            // default: use no heights 
 
521
  setunspecified(estorbitsinput.foresiduals);            // default: no output
 
522
  estorbitsinput.weighting       = eo_noweighting;       // default: unweighted
 
523
  const uint def_eo_nobs         = 1000;                 // default value, apply later
 
524
  setunspecified(estorbitsinput.ifpositions);            // default: no file input
 
525
  estorbitsinput.threshold       = 0;                    // default: ignore coherence estimate
 
526
  estorbitsinput.maxiter         = 0;                    // default: no iteration
 
527
  estorbitsinput.k_alpha         = 3.29;                 // default: norminv(.9995) \approx tinv(.9995,redund) 
 
528
  estorbitsinput.maxfringesaz    = 15;                   //
 
529
  estorbitsinput.maxfringesrg    = 15;                   //
 
530
  setunspecified(estorbitsinput.reforbitfile);           // default: use master as reference
 
531
  setunspecified(estorbitsinput.foobsdata);              // default: do not dump observation data
 
532
  estorbitsinput.poldegree       = 1;                    //
 
533
  estorbitsinput.constrained     = true;                 // default: constrain BPAR0 BPERP1 (define later)
 
534
  // end added by HB ____
 
535
 
 
536
// ====== (default) Methods ======
 
537
  const int16 def_mte_method     = cc_magspace;
 
538
  const int16 def_cc_method     = cc_magfft;
 
539
  const int16 def_fc_method     = fc_magfft;
 
540
  const int16 def_fe_method     = fe_porbits;
 
541
  const int16 def_rs_method     = rs_cc4p;
 
542
  const int16 def_uw_method     = uw_method2;// snaphu, system call, see www
 
543
  const int16 def_s2h_method    = s2h_ambiguity;
 
544
 
 
545
// ______ To check later if default should be used ______
 
546
  mtiminginput.method           = def_mte_method - 999; // default method (repair later)
 
547
  mtiminginput.Nwin             = def_mte_nwin   + 999; // default #windows
 
548
  coarsecorrinput.method        = def_cc_method  - 999; // default method (repair later)
 
549
  coarsecorrinput.Nwin          = def_cc_nwin    + 999; // default #windows
 
550
  fineinput.method              = def_fc_method  - 999; // default method (repair later)
 
551
  fineinput.Nwin                = def_fc_nwin    + 999; // default #windows
 
552
  unwrapinput.method            = def_uw_method  - 999; // default method (repair later)
 
553
  comprefphainput.method        = def_fe_method  - 999; // default method (repair later)
 
554
  comprefphainput.degree        = def_fe_degree  - 999; // default degree polynomial
 
555
  comprefphainput.Npoints       = def_fe_Npoints - 999; // default degree polynomial
 
556
  resampleinput.method          = def_rs_method  - 999; // default method (repair later)
 
557
  slant2hinput.method           = def_s2h_method - 999; // default method (repair later)
 
558
  estorbitsinput.nobs            = 0;                    // set default later
 
559
 
 
560
 
 
561
 
 
562
 
 
563
 
 
564
// ====== Process "inputoptionsfile" ======
 
565
  bool continuereading = true;
 
566
  //while (! optionsfile.eof())                               // read file until end of file.
 
567
  //while (continuereading || ! optionsfile.eof())              // read file until STOP card or if fails exit at end of the file
 
568
  while (continuereading)              // read file until STOP card
 
569
    {
 
570
    linecnt++;
 
571
    optionsfile.getline(eachline,4*ONE27,'\n');                 // get line. [MA] if the line is longer than 4*ONE27 then loops forever.
 
572
    //cerr << "line: " << linecnt << " : " << eachline << endl;
 
573
 
 
574
    if ( optionsfile.eof() ) // && strcmp(keyword,"STOP") )      // [MA] STOP is missing
 
575
      {
 
576
      ERROR << "STOP:   \t is missing"
 
577
            << " in file '" << inputoptionsfile << "'";
 
578
      PRINT_ERROR(ERROR.get_str())
 
579
      WARNING.print("Please make sure the inputfile line: STOP has ended with [eol] character");
 
580
      throw(keyword_error);
 
581
      continuereading = false;                        // break while loop
 
582
      }
 
583
 
 
584
    const int maxwords = 8;   // [GJ, MA]
 
585
    char *word[ maxwords ];
 
586
 
 
587
    char *c = eachline;
 
588
    for ( int i = 0; i < maxwords; i++ )
 
589
    {
 
590
      while ( *c == ' ' || *c == '\t' ) // get rid of leadin white space
 
591
      {
 
592
        c++;                            // next address
 
593
      }
 
594
      word[ i ] = c;                    // pass first char address of a word
 
595
 
 
596
      while ( *c != ' ' && *c != '\t' && *c != '\0' )
 
597
      {
 
598
       c++;
 
599
      }
 
600
 
 
601
      if ( *c != '\0' ) // at last char
 
602
      {
 
603
        *c = '\0';
 
604
        c++;
 
605
      }
 
606
    }
 
607
 
 
608
    char *keyword = word[0];    // start off with the card.
 
609
                                // word[1] --> first argument
 
610
                                // word[2] --> second argument and so on.
 
611
    toupper(keyword);
 
612
 
 
613
    DEBUG << linecnt << ": Read keyword: " << keyword;
 
614
    DEBUG.print();
 
615
 
 
616
// *******************************************************************
 
617
// *** GENERAL
 
618
// *******************************************************************
 
619
    if (!strcmp(keyword,"COMMENT") ||
 
620
        !strcmp(keyword,"C")) 
 
621
      {
 
622
      ;                                                                 // comment: no action 
 
623
      }
 
624
    else if (!strncmp(keyword,"//",2) ||            // assume user comments out
 
625
             !strncmp(keyword,"#",1))                     // with // or '#' as delimiter
 
626
      {                                                                   // but no blank after keyword
 
627
      ;                                                                       // comment: no action
 
628
      }
 
629
    //else if (!strncmp(keyword,'\0',1))          // empty line? crashes
 
630
    else if (!strlen(keyword))                        // empty line
 
631
      {                                                
 
632
      ;                                                                       // comment: no action
 
633
      }
 
634
 
 
635
// **********************************************************************
 
636
    else if (!strcmp(keyword,"BEEP"))     // level of beep output (THE CARD)
 
637
      {                                   // /progress/[warning]/error/ON/OFF
 
638
      //keyword =  word[1] ;    // pass keyword                 // argument
 
639
      //writearg((char*)keyword);
 
640
      keyword = word[1];                  // pass next word       (the argument)
 
641
      writearg(keyword);
 
642
      toupper(keyword);
 
643
      if (!strcmp(keyword,"ERROR"))
 
644
        {
 
645
        TRACE.bellrings(0);
 
646
        DEBUG.bellrings(0);
 
647
        INFO.bellrings(0);
 
648
        PROGRESS.bellrings(0);
 
649
        WARNING.bellrings(0);
 
650
        ERROR.bellrings(1);
 
651
        beeplevel = -1;
 
652
        INFO.print("BEEP: \tbeeping enabled at level: \tERROR");
 
653
        }
 
654
      else if (!strcmp(keyword,"PROGRESS"))
 
655
        {
 
656
        TRACE.bellrings(0);
 
657
        DEBUG.bellrings(0);
 
658
        INFO.bellrings(0);
 
659
        PROGRESS.bellrings(1);
 
660
        WARNING.bellrings(2);
 
661
        ERROR.bellrings(3);
 
662
        beeplevel =  2;
 
663
        INFO.print("BEEP: \tbeeping enabled at level: \tPROGRESS");
 
664
        }
 
665
      else if (!strcmp(keyword,"WARNING"))
 
666
        {
 
667
        TRACE.bellrings(0);
 
668
        DEBUG.bellrings(0);
 
669
        INFO.bellrings(0);
 
670
        PROGRESS.bellrings(0);
 
671
        WARNING.bellrings(1);
 
672
        ERROR.bellrings(2);
 
673
        beeplevel =  1;
 
674
        INFO.print("BEEP: \tbeeping enabled at level: \tWARNING");
 
675
        }
 
676
      else if (!strcmp(keyword,"OFF"))
 
677
        {
 
678
        TRACE.bellrings(0);
 
679
        DEBUG.bellrings(0);
 
680
        INFO.bellrings(0);
 
681
        PROGRESS.bellrings(0);
 
682
        WARNING.bellrings(0);
 
683
        ERROR.bellrings(0);
 
684
        beeplevel =  0;
 
685
        INFO.print("BEEP: \tbeeping disabled");
 
686
        }
 
687
      else if (!strcmp(keyword,"ON")    ||
 
688
               !strncmp(keyword,"//",2) ||      // comment
 
689
               !strncmp(keyword,"#",1) ||       // comment
 
690
         //!strcmp(keyword,\'\\0\'))
 
691
               !(keyword[0] == '\0'))           // no keyword
 
692
//             !strcmp(keyword,""))             // no keyword
 
693
        {
 
694
        TRACE.bellrings(0);
 
695
        DEBUG.bellrings(0);
 
696
        INFO.bellrings(0);
 
697
        PROGRESS.bellrings(1);
 
698
        WARNING.bellrings(2);
 
699
        ERROR.bellrings(3);
 
700
        beeplevel =  2;
 
701
        INFO.print("BEEP: \tbeeping enabled for all levels: \tON");
 
702
        }
 
703
      else
 
704
        {
 
705
        beeplevel = 1;
 
706
        TRACE.bellrings(0);
 
707
        DEBUG.bellrings(0);
 
708
        INFO.bellrings(0);
 
709
        PROGRESS.bellrings(0);
 
710
        WARNING.bellrings(1);
 
711
        ERROR.bellrings(2);
 
712
        WARNING << "BEEP:   line " << linecnt
 
713
             << ": Argument " << keyword 
 
714
             << " not recognized."
 
715
             << " [error/warning/progress/on/off] I used WARNING.";
 
716
        WARNING.print();
 
717
        }
 
718
      } // BEEP key
 
719
 
 
720
// **********************************************************************
 
721
    else if (!strcmp(keyword,"SCREEN")) // level of screen output 
 
722
      {                                 // debug/info/progress/warning or error
 
723
      switch (priorscreen)
 
724
        {
 
725
        case true:
 
726
          WARNING << "SCREEN: line " << linecnt << ": stdout: "
 
727
               << " ignored due to prior occurence.";
 
728
          WARNING.print();
 
729
          break;
 
730
 
 
731
        default:
 
732
          priorscreen = true;
 
733
          //keyword =  word[1] ;        // pass keyword                         // argument
 
734
          keyword = word[1];                    // argument
 
735
          writearg(keyword);
 
736
          toupper(keyword);
 
737
          if (!strcmp(keyword,"INFO"))
 
738
            {
 
739
            TRACE.doprint(0);
 
740
            DEBUG.doprint(0);
 
741
            INFO.doprint(1);
 
742
            PROGRESS.doprint(1);
 
743
            WARNING.doprint(1);
 
744
            ERROR.doprint(1);
 
745
            displevel = 20000 + displevel%10000;        // for cnt #warnings
 
746
            INFO.print("SCREEN: \tverboseness: \t\t\tINFO");
 
747
            }
 
748
          else if (!strcmp(keyword,"PROGRESS"))
 
749
            {
 
750
            TRACE.doprint(0);
 
751
            DEBUG.doprint(0);
 
752
            INFO.doprint(1);
 
753
            PROGRESS.doprint(1);
 
754
            WARNING.doprint(1);
 
755
            ERROR.doprint(1);
 
756
            displevel = 10000 + displevel%10000;        // for cnt #warnings
 
757
            INFO.print("SCREEN: \tverboseness: \t\t\tPROGRESS");
 
758
            }
 
759
          else if (!strcmp(keyword,"DEBUG"))
 
760
            {
 
761
            TRACE.doprint(0);
 
762
            DEBUG.doprint(1);
 
763
            INFO.doprint(1);
 
764
            PROGRESS.doprint(1);
 
765
            WARNING.doprint(1);
 
766
            ERROR.doprint(1);
 
767
            displevel = 30000 + displevel%10000;        // for cnt #warnings
 
768
            INFO.print("SCREEN: \tverboseness: \t\t\tDEBUG");
 
769
            }
 
770
          else if (!strcmp(keyword,"TRACE"))
 
771
            {
 
772
            TRACE.doprint(1);
 
773
            DEBUG.doprint(1);
 
774
            INFO.doprint(1);
 
775
            PROGRESS.doprint(1);
 
776
            WARNING.doprint(1);
 
777
            ERROR.doprint(1);
 
778
            }
 
779
          else if (!strcmp(keyword,"WARNING"))
 
780
            {
 
781
            TRACE.doprint(0);
 
782
            DEBUG.doprint(0);
 
783
            INFO.doprint(0);
 
784
            PROGRESS.doprint(0);
 
785
            WARNING.doprint(1);
 
786
            ERROR.doprint(1);
 
787
            displevel = 0 + displevel%10000;            // for cnt #warnings;
 
788
            INFO.print("SCREEN: \tverboseness: \t\t\tWARNING");
 
789
            }
 
790
          else if (!strcmp(keyword,"ERROR"))
 
791
            {
 
792
            TRACE.doprint(0);
 
793
            DEBUG.doprint(0);
 
794
            INFO.doprint(0);
 
795
            PROGRESS.doprint(0);
 
796
            WARNING.doprint(0);
 
797
            ERROR.doprint(1);
 
798
            displevel = -100 + displevel%10000;         // for cnt #warnings
 
799
            INFO.print("SCREEN: \tverboseness: \t\t\tERROR");
 
800
            }
 
801
          else
 
802
            {
 
803
            TRACE.doprint(0);
 
804
            DEBUG.doprint(1);
 
805
            INFO.doprint(1);
 
806
            PROGRESS.doprint(1);
 
807
            WARNING.doprint(1);
 
808
            ERROR.doprint(1);
 
809
            WARNING << "SCREEN: line " << linecnt
 
810
                 << ": Argument " << keyword 
 
811
                 << " not recognized."
 
812
                 << " [error/warning/progress/info/debug] I used DEBUG.";
 
813
            WARNING.print();
 
814
            displevel = 30000 + displevel%10000;       // for cnt #warnings
 
815
            }
 
816
        } // switch
 
817
      } // SCREEN key
 
818
 
 
819
// **********************************************************************
 
820
    else if (!strcmp(keyword,"MEMORY"))         // available mem in MB for processing in buffers
 
821
      {
 
822
      switch (priormemory)
 
823
        {
 
824
        case true:
 
825
          WARNING << "MEMORY: line " << linecnt
 
826
               << ": ignored due to prior occurence.";
 
827
          WARNING.print();
 
828
          break;
 
829
 
 
830
        default:
 
831
          priormemory = true;
 
832
          //generalinput.memory =  word[1] ;    // pass keyword
 
833
          keyword = word[1];
 
834
          char *pLast = NULL;
 
835
          //generalinput.memory = uint(strtod( keyword, &pLast )); // [MA] try strtoul( keyword, &pLast, 10 ) for uint 
 
836
          generalinput.memory = strtod( keyword, &pLast ); 
 
837
          if ( pLast == keyword ) // fail
 
838
          {
 
839
            ERROR << "memory argument: "  << keyword << " is not valid.";
 
840
            PRINT_ERROR(ERROR.get_str())
 
841
            throw(keyword_error);
 
842
          }
 
843
          writearg(generalinput.memory);
 
844
          if (generalinput.memory > real8(MEMORY_MAX))
 
845
            WARNING << "MEMORY: > " << MEMORY_MAX << " MB seems unlikely.";
 
846
 
 
847
          //generalinput.memory *= 1000000;                       // in B
 
848
          generalinput.memory *= 1e6;                       // convert Mb --> b
 
849
        } // switch
 
850
      } // MEMORY card
 
851
 
 
852
// **********************************************************************
 
853
    else if (!strcmp(keyword,"BATCH"))                  // overrides interactive mode
 
854
      {
 
855
      switch (priorbatch)
 
856
        {
 
857
        case true:
 
858
          WARNING << "BATCH: line: " << linecnt << ": "
 
859
               << "ignored due to prior occurence.";
 
860
          WARNING.print();
 
861
          break;
 
862
        default:
 
863
          priorbatch = true;                            // flag for occurence
 
864
         // keyword =  word[1] ;        // pass keyword                 // argument
 
865
          keyword = word[1];                  // pass next word       (the argument)
 
866
          writearg(keyword);
 
867
    toupper(keyword);
 
868
          if (!strcmp(keyword,"OFF"))
 
869
            generalinput.interactive = true;
 
870
          else if (!strcmp(keyword,"ON")    ||
 
871
                   !strncmp(keyword,"//",2) ||          // comment
 
872
                   !strncmp(keyword,"#",1)  ||          // comment
 
873
                   !(keyword[0] == '\0'))               // no keyword
 
874
            generalinput.interactive = false;
 
875
          else
 
876
            {
 
877
            generalinput.interactive = true;
 
878
            WARNING << "BATCH: line: " << linecnt << ": "
 
879
                 << "argument: " << keyword 
 
880
                 << " not recognized, interactive processing.";
 
881
            WARNING.print();
 
882
            }
 
883
        } // switch
 
884
      } // BATCH key
 
885
 
 
886
// **********************************************************************
 
887
    else if (!strcmp(keyword,"OVERWRITE")) 
 
888
      {
 
889
      switch (prioroverwrite)
 
890
        {
 
891
        case true:
 
892
          WARNING << "OVERWRITE: line: " << linecnt << ": "
 
893
               << "ignored due to prior occurence.";
 
894
          WARNING.print();
 
895
          break;
 
896
        default:
 
897
          prioroverwrite = true;                                // flag for occurence
 
898
          keyword = word[1];                  // pass next word       (the argument)
 
899
          writearg(keyword);
 
900
          toupper(keyword);
 
901
          if (!strcmp(keyword,"OFF")) 
 
902
            generalinput.overwrit = false;
 
903
          else if (!strcmp(keyword,"ON")    ||
 
904
                   !strncmp(keyword,"//",2) ||          // comment
 
905
                   !strncmp(keyword,"#",1)  ||          // comment
 
906
                   !(keyword[0] == '\0'))               // no keyword
 
907
            generalinput.overwrit = true;
 
908
          else
 
909
            {
 
910
            generalinput.overwrit=false;                    // don't overwrite files
 
911
            WARNING << "OVERWRITE: line " << linecnt 
 
912
                 << ": argument: " << keyword 
 
913
                 << " not recognized, existing files are not overwritten.";
 
914
            WARNING.print();
 
915
            }
 
916
        } // switch
 
917
      } // OVERWRITE key
 
918
 
 
919
// **********************************************************************
 
920
    else if (!strcmp(keyword,"LISTINPUT")) 
 
921
      {
 
922
      switch (priorlistinput)
 
923
        {
 
924
        case true:
 
925
          WARNING << "LISTINPUT: line: " << linecnt << ": "
 
926
               << "ignored due to prior occurence.";
 
927
          WARNING.print();
 
928
          break;
 
929
        default:
 
930
          priorlistinput = true;                                // flag for occurence
 
931
          keyword = word[1];                  // pass next word       (the argument)
 
932
          writearg(keyword);
 
933
          toupper(keyword);
 
934
          if (!strcmp(keyword,"OFF")) 
 
935
            listinput = false;
 
936
          else if (!strcmp(keyword,"ON")    ||
 
937
                   !strncmp(keyword,"//",2) ||          // comment
 
938
                   !strncmp(keyword,"#",1)  ||          // comment
 
939
                   !(keyword[0] == '\0'))               // no keyword
 
940
            listinput = true;
 
941
          else
 
942
            {
 
943
            listinput = true;                                   // default list input
 
944
            WARNING << "LISTINPUT: line " << linecnt 
 
945
                 << ": argument: " << keyword 
 
946
                 << " not recognized, input will be appended to logfile.";
 
947
            WARNING.print();
 
948
            }
 
949
        } // switch
 
950
      } // LISTINPUT key
 
951
 
 
952
// **********************************************************************
 
953
    else if (!strcmp(keyword,"ONLYPROCESS"))     // process only one step
 
954
      {
 
955
      // Read argument and set onlyprocess to value for filling
 
956
      //  the flag input array 'process[NUMPROCESSES]' after reading reset input
 
957
      //  to avoid interference with PROCESS cards (ONLYPROCESS overrides)
 
958
      //
 
959
      if (onlyprocess == -1)                             // check multiple occurences
 
960
        {
 
961
          keyword = word[1];                  // pass next word       (the argument)
 
962
        writearg(keyword);
 
963
    toupper(keyword);
 
964
        if      (!strcmp(keyword,"M_READFILES"))
 
965
          onlyprocess=pr_m_readfiles;
 
966
        else if (!strcmp(keyword,"M_CROP"))
 
967
          onlyprocess=pr_m_crop;
 
968
//____RaffaeleNutricato START MODIFICATION SECTION 5
 
969
        else if (!strcmp(keyword,"M_OVS"))
 
970
          onlyprocess=pr_m_oversample;
 
971
//____RaffaeleNutricato END MODIFICATION SECTION 5
 
972
        else if (!strcmp(keyword,"M_PORBITS"))
 
973
          onlyprocess=pr_m_porbits;
 
974
        else if (!strcmp(keyword,"M_MORBITS")) // [HB]
 
975
          onlyprocess=pr_m_morbits;
 
976
        else if (!strcmp(keyword,"M_SIMAMP")) // [MA]
 
977
          onlyprocess=pr_m_simamp;
 
978
        else if (!strcmp(keyword,"M_TIMING"))
 
979
          onlyprocess=pr_m_mtiming;
 
980
        else if (!strcmp(keyword,"M_FILTAZI"))
 
981
          onlyprocess=pr_m_filtazi;
 
982
        else if (!strcmp(keyword,"FILTRANGE"))
 
983
          {
 
984
          onlyprocess=pr_m_filtrange;
 
985
          onlyprocess=pr_s_filtrange;
 
986
          }
 
987
        else if (!strcmp(keyword,"M_EXTRA"))
 
988
          onlyprocess=pr_m_EXTRA;
 
989
 
 
990
        else if (!strcmp(keyword,"S_READFILES"))
 
991
          onlyprocess=pr_s_readfiles;
 
992
        else if (!strcmp(keyword,"S_MORBITS")) // [HB]
 
993
          onlyprocess=pr_s_morbits;
 
994
        else if (!strcmp(keyword,"S_CROP"))
 
995
          onlyprocess=pr_s_crop;
 
996
//____RaffaeleNutricato START MODIFICATION SECTION 6
 
997
        else if (!strcmp(keyword,"S_OVS"))
 
998
          onlyprocess=pr_s_oversample;
 
999
//____RaffaeleNutricato END MODIFICATION SECTION 6
 
1000
        else if (!strcmp(keyword,"S_PORBITS"))
 
1001
          onlyprocess=pr_s_porbits;
 
1002
        else if (!strcmp(keyword,"S_FILTAZI"))
 
1003
          onlyprocess=pr_s_filtazi;
 
1004
        else if (!strcmp(keyword,"RESAMPLE"))
 
1005
          onlyprocess=pr_s_resample;
 
1006
        else if (!strcmp(keyword,"S_EXTRA"))
 
1007
          onlyprocess=pr_s_EXTRA;
 
1008
 
 
1009
        else if (!strcmp(keyword,"COARSEORB"))
 
1010
          onlyprocess=pr_i_coarse;
 
1011
        else if (!strcmp(keyword,"COARSECORR"))
 
1012
          onlyprocess=pr_i_coarse2;
 
1013
        else if (!strcmp(keyword,"FINE"))
 
1014
          onlyprocess=pr_i_fine;                         // see methodselector
 
1015
        else if (!strcmp(keyword,"RELTIMING")) // [FvL]
 
1016
          onlyprocess=pr_i_timing;
 
1017
        else if (!strcmp(keyword,"DEMASSIST")) // [FvL]
 
1018
          onlyprocess=pr_i_demassist;
 
1019
        else if (!strcmp(keyword,"COREGPM"))
 
1020
          onlyprocess=pr_i_coregpm;
 
1021
        else if (!strcmp(keyword,"INTERFERO"))
 
1022
          onlyprocess=pr_i_interfero;
 
1023
        else if (!strcmp(keyword,"COHERENCE"))
 
1024
          onlyprocess=pr_i_coherence;
 
1025
        else if (!strcmp(keyword,"FILTPHASE"))
 
1026
          onlyprocess=pr_i_filtphase;
 
1027
        else if (!strcmp(keyword,"COMPREFPHA"))
 
1028
          onlyprocess=pr_i_comprefpha;
 
1029
        else if (!strcmp(keyword,"SUBTRREFPHA"))
 
1030
          onlyprocess=pr_i_subtrrefpha;
 
1031
        else if (!strcmp(keyword,"COMPREFDEM"))
 
1032
          onlyprocess=pr_i_comprefdem;
 
1033
        else if (!strcmp(keyword,"SUBTRREFDEM"))
 
1034
          onlyprocess=pr_i_subtrrefdem;
 
1035
        else if (!strcmp(keyword,"UNWRAP"))
 
1036
          onlyprocess=pr_i_unwrap;                       // see methodselector
 
1037
        else if (!strcmp(keyword,"ESTORBITS")) // [HB]
 
1038
          onlyprocess=pr_i_estorbits;         
 
1039
        else if (!strcmp(keyword,"SLANT2H"))
 
1040
          onlyprocess=pr_i_slant2h;
 
1041
        else if (!strcmp(keyword,"GEOCODE"))
 
1042
          onlyprocess=pr_i_geocoding;
 
1043
        else if (!strcmp(keyword,"DINSAR"))
 
1044
          onlyprocess=pr_i_dinsar;
 
1045
        else if (!strcmp(keyword,"I_EXTRA2"))
 
1046
          onlyprocess=pr_i_EXTRA2;
 
1047
        else
 
1048
          {
 
1049
          ERROR << "ONLYPROCESS: line " << linecnt << ": Argument " 
 
1050
                   << keyword << " not recognized.";
 
1051
          PRINT_ERROR(ERROR.get_str())
 
1052
          throw(keyword_error);
 
1053
          }
 
1054
        INFO << "ONLYPROCESS: \tonly processing step: \t\t" << keyword;
 
1055
        INFO.print();
 
1056
        }
 
1057
      else
 
1058
        {
 
1059
        WARNING << "ONLYPROCESS: more than one occurence of card, ignored line: "
 
1060
                   << linecnt << ".";
 
1061
        WARNING.print();
 
1062
 
 
1063
        }
 
1064
      }
 
1065
 
 
1066
// **********************************************************************
 
1067
    else if (!strcmp(keyword,"PROCESS"))                 // which routine to run
 
1068
      {
 
1069
      if (onlyprocess+1)                                 // initialized to -1;
 
1070
        {
 
1071
        WARNING << "PROCESS card on line " << linecnt 
 
1072
             << " ignored due to presence of ONLYPROCESS card.";
 
1073
        WARNING.print();
 
1074
        }
 
1075
      else
 
1076
        {
 
1077
          keyword = word[1];                  // pass next word       (the argument)
 
1078
        writearg(keyword);
 
1079
    toupper(keyword);
 
1080
        if (!strcmp(keyword,"M_READFILES"))
 
1081
          generalinput.process[pr_m_readfiles] = 1;
 
1082
        else if (!strcmp(keyword,"M_CROP"))
 
1083
          generalinput.process[pr_m_crop]   = 1;
 
1084
//____RaffaeleNutricato START MODIFICATION SECTION 7
 
1085
        else if (!strcmp(keyword,"M_OVS"))
 
1086
          generalinput.process[pr_m_oversample]   = 1; 
 
1087
//____RaffaeleNutricato END MODIFICATION SECTION 7
 
1088
        else if (!strcmp(keyword,"M_PORBITS"))
 
1089
          generalinput.process[pr_m_porbits]   = 1;
 
1090
        else if (!strcmp(keyword,"M_MORBITS")) // [HB]
 
1091
          generalinput.process[pr_m_morbits]   = 1;
 
1092
        else if (!strcmp(keyword,"M_SIMAMP"))         // [MA]
 
1093
          generalinput.process[pr_m_simamp]    = 1;
 
1094
        else if (!strcmp(keyword,"M_TIMING"))
 
1095
          generalinput.process[pr_m_mtiming]   = 1;
 
1096
        else if (!strcmp(keyword,"M_FILTAZI"))
 
1097
          generalinput.process[pr_m_filtazi]   = 1;
 
1098
        else if (!strcmp(keyword,"FILTRANGE"))
 
1099
          {
 
1100
          generalinput.process[pr_m_filtrange] = 1;     // use for s_ as well
 
1101
          generalinput.process[pr_s_filtrange] = 1;
 
1102
          }
 
1103
        else if (!strcmp(keyword,"M_EXTRA"))
 
1104
          generalinput.process[pr_m_EXTRA] = 1;
 
1105
 
 
1106
        else if (!strcmp(keyword,"S_READFILES"))
 
1107
          generalinput.process[pr_s_readfiles] = 1;
 
1108
        else if (!strcmp(keyword,"S_MORBITS")) // [HB]
 
1109
          generalinput.process[pr_s_morbits]   = 1;
 
1110
        else if (!strcmp(keyword,"S_CROP"))
 
1111
          generalinput.process[pr_s_crop]   = 1;
 
1112
//____RaffaeleNutricato START MODIFICATION SECTION 8
 
1113
        else if (!strcmp(keyword,"S_OVS"))
 
1114
          generalinput.process[pr_s_oversample]   = 1;
 
1115
//____RaffaeleNutricato END MODIFICATION SECTION 8
 
1116
        else if (!strcmp(keyword,"S_PORBITS"))
 
1117
          generalinput.process[pr_s_porbits]   = 1;
 
1118
        else if (!strcmp(keyword,"S_FILTAZI"))
 
1119
          generalinput.process[pr_s_filtazi]   = 1;
 
1120
        else if (!strcmp(keyword,"RESAMPLE"))
 
1121
          generalinput.process[pr_s_resample]  = 1;
 
1122
        else if (!strcmp(keyword,"S_EXTRA"))
 
1123
          generalinput.process[pr_s_EXTRA] = 1;
 
1124
 
 
1125
        else if (!strcmp(keyword,"COARSEORB"))
 
1126
          generalinput.process[pr_i_coarse]    = 1;
 
1127
        else if (!strcmp(keyword,"COARSECORR"))
 
1128
          generalinput.process[pr_i_coarse2]   = 1;
 
1129
        else if (!strcmp(keyword,"FINE"))
 
1130
          generalinput.process[pr_i_fine]      = 1;
 
1131
        else if (!strcmp(keyword,"RELTIMING"))         // [FvL]
 
1132
          generalinput.process[pr_i_timing]    = 1;
 
1133
        else if (!strcmp(keyword,"DEMASSIST"))         // [FvL]
 
1134
          generalinput.process[pr_i_demassist]    = 1;
 
1135
        else if (!strcmp(keyword,"COREGPM"))
 
1136
          generalinput.process[pr_i_coregpm]   = 1;
 
1137
        else if (!strcmp(keyword,"COMPREFPHA"))
 
1138
          generalinput.process[pr_i_comprefpha] = 1;
 
1139
        else if (!strcmp(keyword,"SUBTRREFPHA"))
 
1140
          generalinput.process[pr_i_subtrrefpha] = 1;
 
1141
        else if (!strcmp(keyword,"COMPREFDEM"))
 
1142
          generalinput.process[pr_i_comprefdem] = 1;
 
1143
        else if (!strcmp(keyword,"SUBTRREFDEM"))
 
1144
          generalinput.process[pr_i_subtrrefdem] = 1;
 
1145
        else if (!strcmp(keyword,"INTERFERO"))
 
1146
          generalinput.process[pr_i_interfero] = 1;
 
1147
        else if (!strcmp(keyword,"COHERENCE"))
 
1148
          generalinput.process[pr_i_coherence] = 1;
 
1149
        else if (!strcmp(keyword,"FILTPHASE"))
 
1150
          generalinput.process[pr_i_filtphase] = 1;
 
1151
        else if (!strcmp(keyword,"UNWRAP"))
 
1152
          generalinput.process[pr_i_unwrap]    = 1;
 
1153
        else if (!strcmp(keyword,"ESTORBITS"))    // [HB]
 
1154
          generalinput.process[pr_i_estorbits]    = 1;
 
1155
        else if (!strcmp(keyword,"SLANT2H"))
 
1156
          generalinput.process[pr_i_slant2h]   = 1;
 
1157
        else if (!strcmp(keyword,"GEOCODE"))
 
1158
          generalinput.process[pr_i_geocoding] = 1;
 
1159
        else if (!strcmp(keyword,"DINSAR"))
 
1160
          generalinput.process[pr_i_dinsar] = 1;
 
1161
 
 
1162
        else if (!strcmp(keyword,"I_EXTRA2"))
 
1163
          generalinput.process[pr_i_EXTRA2] = 1;
 
1164
        else
 
1165
          {
 
1166
          ERROR << "PROCESS: line " << linecnt 
 
1167
               << ": Argument " << keyword 
 
1168
               << " not recognized.";
 
1169
          PRINT_ERROR(ERROR.get_str())
 
1170
          throw(keyword_error);
 
1171
          }
 
1172
        INFO << "PROCESS: \tI will process step: \t\t" << keyword;
 
1173
        INFO.print();
 
1174
        }
 
1175
      }
 
1176
 
 
1177
// **********************************************************************
 
1178
    else if (!strcmp(keyword,"ELLIPSOID"))            // ref. system
 
1179
      {                                               //  inputoptionsfile
 
1180
      ellipsoid = true;                               // use below 
 
1181
      keyword = word[1];
 
1182
      char *keyword2 = word[2]; 
 
1183
      writearg(keyword);
 
1184
      toupper(keyword);
 
1185
      writearg(keyword2);
 
1186
      if (!strcmp(keyword,"WGS84"))
 
1187
        {
 
1188
        ellipsinput   = WGS84;// default
 
1189
        }
 
1190
      else if (!strcmp(keyword,"GRS80"))
 
1191
        {
 
1192
        WARNING.print("ELLIPS: not ok, sat. ephemerides should be in this system.");
 
1193
              input_ell GRS80(6378137.0,6356752.3);
 
1194
              GRS80.set_name("GRS80");
 
1195
              ellipsinput = GRS80;// copy
 
1196
        }
 
1197
      else if (!strcmp(keyword,"BESSEL"))
 
1198
        {
 
1199
        WARNING.print("ELLIPS: not ok, sat. ephemerides should be in this system.");
 
1200
              input_ell BESSEL(6377397.155,6356078.963);
 
1201
              BESSEL.set_name("BESSEL");
 
1202
              ellipsinput = BESSEL;// copy
 
1203
        }
 
1204
      else if (isdigit(keyword2[0]))                      // likely to be a,b
 
1205
        {
 
1206
        WARNING.print("ELLIPS: not ok, sat. ephemerides should be in this system.");
 
1207
        input_ell ELL_USER_DEFINED(atof(keyword),atof(keyword2));// a,b
 
1208
              ELL_USER_DEFINED.set_name("user_defined");
 
1209
        ellipsinput = ELL_USER_DEFINED;// copy
 
1210
        if (ellipsinput.a<ellipsinput.b || ellipsinput.b<EPS)
 
1211
          {
 
1212
          ERROR << "ELLIPSOID keyword (real8A real8B): B==0 or A<B: "
 
1213
               << ellipsinput.a << "<" << ellipsinput.b 
 
1214
               << " at line " << linecnt << ".";
 
1215
                PRINT_ERROR(ERROR.get_str())
 
1216
                throw(keyword_error);
 
1217
          }
 
1218
        }
 
1219
      else
 
1220
        {
 
1221
        PRINT_ERROR("unknown argument for ellipsoid card.")
 
1222
        throw(keyword_error);
 
1223
        }
 
1224
      INFO << "ELLIPSOID: \tsemimajor=" << ellipsinput.a
 
1225
           << ", semiminor=" << ellipsinput.b << "; line " << linecnt << ".";
 
1226
      INFO.print();
 
1227
      }
 
1228
 
 
1229
// **********************************************************************
 
1230
    else if (!strcmp(keyword,"M_RESFILE"))            // resultfile filename
 
1231
      {                                               
 
1232
      //generalinput.m_resfile =  word[1] ;     // pass keyword
 
1233
      keyword = word[1];
 
1234
      // strcpy(generalinput.m_resfile, keyword);
 
1235
      strcpy(generalinput.m_resfile, keyword);
 
1236
      writearg(generalinput.m_resfile);
 
1237
      }
 
1238
 
 
1239
// **********************************************************************
 
1240
    else if (!strcmp(keyword,"S_RESFILE"))            // resultfile filename
 
1241
      {                                               
 
1242
      keyword = word[1];
 
1243
      strcpy(generalinput.s_resfile, keyword);
 
1244
      writearg(generalinput.s_resfile);
 
1245
      }
 
1246
 
 
1247
// **********************************************************************
 
1248
    else if (!strcmp(keyword,"LOGFILE"))              // logfile filename
 
1249
      {                                               
 
1250
      keyword = word[1];
 
1251
      strcpy(generalinput.logfile, keyword);
 
1252
      writearg(generalinput.logfile);
 
1253
      }
 
1254
 
 
1255
// **********************************************************************
 
1256
    else if (!strcmp(keyword,"I_RESFILE"))            // interferogram.out
 
1257
      {                                               
 
1258
      keyword = word[1];
 
1259
      strcpy(generalinput.i_resfile, keyword);
 
1260
      writearg(generalinput.i_resfile);
 
1261
      }
 
1262
 
 
1263
// **********************************************************************
 
1264
    else if (!strcmp(keyword,"ORB_INTERP"))           // orbit
 
1265
      {                                               
 
1266
      //keyword =  word[1] ;    // pass keyword                       // argument
 
1267
      keyword = word[1]; 
 
1268
      writearg(keyword);
 
1269
      toupper(keyword);
 
1270
      if (!strcmp(keyword,"POLYFIT"))
 
1271
        {
 
1272
        INFO.print("ORB_INTERP:  polynomial fit for interpolation");
 
1273
        generalinput.orb_interp = ORB_DEFAULT;// depends on number of points
 
1274
        // ___ Check second optional argument with degree ___
 
1275
        // keyword =  word[1] ;  // pass keyword
 
1276
        char *keyword2= word[2];
 
1277
        int32 degree = atoi(keyword2); 
 
1278
        if (degree > 0)// atoi returns 0 if not convertible
 
1279
          {
 
1280
          generalinput.orb_interp = degree;
 
1281
          INFO << "ORB_INTERP:  second argument read: degree = " << degree;
 
1282
          INFO.print();
 
1283
          }
 
1284
        }
 
1285
      else if (!strcmp(keyword,"SPLINE"))
 
1286
        {
 
1287
        INFO.print("ORB_INTERP:  natural cubic splines used fit interpolation");
 
1288
        generalinput.orb_interp = ORB_SPLINE;// natural cubic splines
 
1289
        }
 
1290
      else
 
1291
        {
 
1292
        WARNING.print("argument ORB_INTERP not recognized, using polyfit");
 
1293
        generalinput.orb_interp = ORB_DEFAULT;// depends on number of points
 
1294
        }
 
1295
      }
 
1296
 
 
1297
// **********************************************************************
 
1298
    else if (!strcmp(keyword,"ORB_PRM"))           // orbit parameters
 
1299
      {                                               
 
1300
      keyword = word[1];    // pass keyword                       // argument 
 
1301
      writearg(keyword);
 
1302
      toupper(keyword);
 
1303
      if (!strcmp(keyword,"POSITION") || !strcmp(keyword,"POS") )
 
1304
        {
 
1305
        INFO.print("ORB_PRM:  identified, using position state vectors for orbit interpolation");
 
1306
        generalinput.orb_prm = ORB_PRM_POS;// user positional state vectors only
 
1307
        }
 
1308
      else if (!strcmp(keyword,"POSVEL"))
 
1309
        {
 
1310
        INFO.print("ORB_PRM:  identified, using positions and velocities for orbit interpolation");
 
1311
        generalinput.orb_prm = ORB_PRM_VEL;// include velocity vectors too
 
1312
        }
 
1313
      else
 
1314
        {
 
1315
        WARNING.print("argument ORB_PRM not identified, using position state vectors only (this ignores any velocity column.)");
 
1316
        generalinput.orb_prm = ORB_PRM_POS;// default positional.
 
1317
        }
 
1318
      }
 
1319
 
 
1320
// **********************************************************************
 
1321
    else if (!strcmp(keyword,"DUMPBASELINE"))         // eval on grid
 
1322
      {                                               
 
1323
//      generalinput.dumpbaselineL >> generalinput.dumpbaselineP =  word[1] ;   // pass keyword
 
1324
          keyword = word[1];
 
1325
          char *keyword2= word[2]; // in local scope
 
1326
          generalinput.dumpbaselineL = atoi( keyword ) ;
 
1327
          generalinput.dumpbaselineP = atoi( keyword2 );
 
1328
          writearg(generalinput.dumpbaselineL);
 
1329
          writearg(generalinput.dumpbaselineP);
 
1330
      if (generalinput.dumpbaselineL==0 || generalinput.dumpbaselineP==0)
 
1331
        {
 
1332
        ERROR << "DUMPBASELINE: " << generalinput.dumpbaselineL
 
1333
             << " " << generalinput.dumpbaselineP << " line: "
 
1334
             << linecnt << ": ==0.\n";
 
1335
        PRINT_ERROR(ERROR.get_str())
 
1336
        throw(keyword_error);
 
1337
        }
 
1338
      }
 
1339
 
 
1340
// **********************************************************************
 
1341
    else if (!strcmp(keyword,"PREVIEW"))        // system call to cpxfiddle to get SUNraster
 
1342
      {
 
1343
      //keyword =  word[1] ;    // pass keyword                 // argument
 
1344
      keyword = word[1];                        // argument
 
1345
      writearg(keyword);
 
1346
      toupper(keyword);
 
1347
      if (!strcmp(keyword,"OFF"))
 
1348
        {
 
1349
        generalinput.preview = 0;
 
1350
        INFO.print("PREVIEW: \tOFF: generation of SUNraster files disabled.");
 
1351
        }
 
1352
      else if (!strcmp(keyword,"XV"))
 
1353
        {
 
1354
        generalinput.preview = 2;
 
1355
        INFO.print("PREVIEW: \tON: generation of SUNraster files enabled + XV sytem call.");
 
1356
        }
 
1357
      else if (!strcmp(keyword,"ON")    ||
 
1358
               !strncmp(keyword,"//",2) ||              // comment
 
1359
               !strncmp(keyword,"#",1)  ||              // comment
 
1360
               !(keyword[0] == '\0'))                   // no keyword
 
1361
        {
 
1362
        generalinput.preview = 1;
 
1363
        INFO.print("PREVIEW: \tON: generation of SUNraster files enabled.");
 
1364
        }
 
1365
      else
 
1366
        {
 
1367
        generalinput.preview = 0;
 
1368
        WARNING << "PREVIEW: line: " << linecnt << ": "
 
1369
             << "argument: " << keyword 
 
1370
             << " not recognized, no preview generated.";
 
1371
        WARNING.print();
 
1372
        }
 
1373
      } // PREVIEW key
 
1374
 
 
1375
// **********************************************************************
 
1376
    else if (!strcmp(keyword,"HEIGHT"))               // mean height or for CROP
 
1377
      {
 
1378
      //generalinput.terrain_height =  word[1] ;        // pass keyword
 
1379
          keyword = word[1];
 
1380
          char *pLast = NULL;
 
1381
          generalinput.terrain_height = strtod( keyword, &pLast );
 
1382
          if ( pLast == keyword ) // fail
 
1383
          {
 
1384
            ERROR << "Height argument: "  << keyword << " is not valid.";
 
1385
            PRINT_ERROR(ERROR.get_str())
 
1386
            throw(keyword_error);
 
1387
          }
 
1388
      writearg(generalinput.terrain_height);
 
1389
      }
 
1390
 
 
1391
// **********************************************************************
 
1392
    else if (!strcmp(keyword,"TIEPOINT"))          // lat/lon/hei dec.degrees
 
1393
      {
 
1394
 
 
1395
        keyword = word[1];
 
1396
        char *pLast, *pLast2, *pLast3 = NULL;
 
1397
        generalinput.tiepoint.x = strtod( keyword, &pLast  );
 
1398
        generalinput.tiepoint.y = strtod( word[2], &pLast2 ); // 2nd arg
 
1399
                    generalinput.tiepoint.z = strtod( word[3], &pLast3 ); // 3rd arg
 
1400
        if ( pLast == keyword || pLast2 == word[2] || pLast3 == word[3] ) // fail
 
1401
        {
 
1402
          ERROR << "Tiepoints: "  << keyword 
 
1403
          << " " << word[2] 
 
1404
          << " " << word[3] << " are not valid.";
 
1405
          PRINT_ERROR(ERROR.get_str())
 
1406
          throw(keyword_error);
 
1407
        }
 
1408
       writearg(generalinput.tiepoint.x);
 
1409
       writearg(generalinput.tiepoint.y);
 
1410
       writearg(generalinput.tiepoint.z);
 
1411
      }
 
1412
 
 
1413
// **********************************************************************
 
1414
    else if (!strcmp(keyword,"STOP"))                 // STOP interpreting input
 
1415
      {
 
1416
      INFO.print("STOP:   \tEncountered.");
 
1417
      DEBUG << "STOP card encountered at line "
 
1418
           << linecnt << endl;
 
1419
      DEBUG.print();
 
1420
      continuereading = false;                        // break while loop
 
1421
      }
 
1422
 
 
1423
// *******************************************************************
 
1424
// *** ?_READFILES
 
1425
// *******************************************************************
 
1426
    else if (!strcmp(keyword,"M_IN_METHOD"))         // ERS or ASAR ENVISAT
 
1427
      {                                               
 
1428
      //filename =  word[1] ;   // pass keyword
 
1429
      keyword = word[1];
 
1430
      writearg(keyword);
 
1431
      toupper(keyword);
 
1432
 
 
1433
      if (!strcmp(keyword,"ERS"))
 
1434
        m_readfilesinput.sensor_id=SLC_ERS;          // default ers
 
1435
      else if (!strcmp(keyword,"ERS-1"))             // ers
 
1436
        m_readfilesinput.sensor_id=SLC_ERS;
 
1437
      else if (!strcmp(keyword,"ERS1"))              // ers
 
1438
        m_readfilesinput.sensor_id=SLC_ERS;
 
1439
      else if (!strcmp(keyword,"ERS-2"))             // ers
 
1440
        m_readfilesinput.sensor_id=SLC_ERS;
 
1441
      else if (!strcmp(keyword,"ERS2"))              // ers
 
1442
        m_readfilesinput.sensor_id=SLC_ERS;
 
1443
      else if (!strcmp(keyword,"ERS_N1"))           // ers in envisat file format [MA]; treat as ASAR
 
1444
        //m_readfilesinput.sensor_id=SLC_ASAR;
 
1445
        m_readfilesinput.sensor_id=SLC_ERS_N1;
 
1446
      else if (!strcmp(keyword,"N1"))                // envisat
 
1447
        m_readfilesinput.sensor_id=SLC_ASAR;
 
1448
      else if (!strcmp(keyword,"ASAR"))              // envisat
 
1449
        m_readfilesinput.sensor_id=SLC_ASAR;
 
1450
      else if (!strcmp(keyword,"ENVISAT"))           // envisat
 
1451
        m_readfilesinput.sensor_id=SLC_ASAR;
 
1452
      else if (!strcmp(keyword,"ASAR_AP_HH"))        // envisat Alternating Pol. HH
 
1453
        m_readfilesinput.sensor_id=SLC_ASAR_AP_HH;
 
1454
      else if (!strcmp(keyword,"ASAR_AP_VV"))        // envisat Alternating Pol. VV
 
1455
        m_readfilesinput.sensor_id=SLC_ASAR_AP_VV;
 
1456
      else if (!strcmp(keyword,"ATLANTIS"))          // radarsat ceos reader
 
1457
        m_readfilesinput.sensor_id=SLC_RSAT;
 
1458
      else if (!strcmp(keyword,"RSAT"))              // radarsat
 
1459
        m_readfilesinput.sensor_id=SLC_RSAT;
 
1460
      else if (!strcmp(keyword,"RADARSAT"))          // radarsat
 
1461
        m_readfilesinput.sensor_id=SLC_RSAT;
 
1462
      else if (!strcmp(keyword,"RADARSAT-1"))        // radarsat
 
1463
        m_readfilesinput.sensor_id=SLC_RSAT;
 
1464
      else if (!strcmp(keyword,"JERS"))              // jers
 
1465
        m_readfilesinput.sensor_id=SLC_JERS;
 
1466
      else if (!strcmp(keyword,"J-ERS"))             // jers
 
1467
        m_readfilesinput.sensor_id=SLC_JERS;
 
1468
      else if (!strcmp(keyword,"ALOS"))              // alos FBS  [DON] 
 
1469
        m_readfilesinput.sensor_id=SLC_ALOS;
 
1470
      else if (!strcmp(keyword,"TSX"))               // TSX    [PM]
 
1471
        m_readfilesinput.sensor_id=SLC_TSX;
 
1472
      else if (!strcmp(keyword,"TERRASARX"))         // TSX
 
1473
        m_readfilesinput.sensor_id=SLC_TSX;
 
1474
      else if (!strcmp(keyword,"TERRASAR-X"))        // TSX
 
1475
        m_readfilesinput.sensor_id=SLC_TSX;
 
1476
      else if (!strcmp(keyword,"RS2"))               // RS2  [MA]
 
1477
        m_readfilesinput.sensor_id=SLC_RS2;
 
1478
      else if (!strcmp(keyword,"RADARSAT-2"))        // RS2
 
1479
        m_readfilesinput.sensor_id=SLC_RS2;
 
1480
      else if (!strcmp(keyword,"CSK"))               // CSK  [PD]
 
1481
        m_readfilesinput.sensor_id=SLC_CSK;
 
1482
      else if (!strcmp(keyword,"CSX"))               // CSK  [PD]
 
1483
        m_readfilesinput.sensor_id=SLC_CSK;
 
1484
      else if (!strcmp(keyword,"GAMMA"))             // GAMMA [BO]
 
1485
        m_readfilesinput.sensor_id=SLC_GAMMA;        
 
1486
      else
 
1487
        {
 
1488
        ERROR << "M_IN_METHOD: method " <<  keyword
 
1489
             << " not known for reading input files on line "
 
1490
             << linecnt << ".";
 
1491
            PRINT_ERROR(ERROR.get_str())
 
1492
            throw(keyword_error);
 
1493
        }
 
1494
      }
 
1495
 
 
1496
// **********************************************************************
 
1497
    else if (!strcmp(keyword,"M_IN_VOL"))            // volumefile filename
 
1498
      {                                               
 
1499
      //m_readfilesinput.volfile =  word[1] ;   // pass keyword
 
1500
      strcpy(m_readfilesinput.volfile, word[1]);          // pass keyword
 
1501
      writearg(m_readfilesinput.volfile);
 
1502
      }
 
1503
 
 
1504
// **********************************************************************
 
1505
    else if (!strcmp(keyword,"M_IN_LEA"))            // leaderfile filename
 
1506
      {                                               
 
1507
      strcpy(m_readfilesinput.leaderfile, word[1]);          // pass keyword
 
1508
      writearg(m_readfilesinput.leaderfile);
 
1509
      }
 
1510
 
 
1511
// **********************************************************************
 
1512
    else if (!strcmp(keyword,"M_IN_NULL"))           // nullfile filename
 
1513
      {                                               
 
1514
      strcpy(m_readfilesinput.nullfile, word[1]);          // pass keyword
 
1515
      writearg(m_readfilesinput.nullfile);
 
1516
      }
 
1517
 
 
1518
// **********************************************************************
 
1519
    else if (!strcmp(keyword,"M_IN_DAT"))            // datafile filename
 
1520
      {                                               
 
1521
      strcpy(m_readfilesinput.datfile, word[1]);          // pass keyword
 
1522
      writearg(m_readfilesinput.datfile);
 
1523
      }
 
1524
 
 
1525
// **********************************************************************
 
1526
    else if (!strcmp(keyword,"M_RG_T_ERROR"))            // master timing error
 
1527
      {                                               
 
1528
       keyword = word[1];
 
1529
       char *pLast = NULL;
 
1530
       m_readfilesinput.rg_timing_error= strtod( keyword, &pLast );
 
1531
       if ( pLast == keyword ) // fail
 
1532
        {
 
1533
          ERROR << "M_RG_T_ERROR argument: "  << keyword << " is not valid.";
 
1534
          PRINT_ERROR(ERROR.get_str())
 
1535
          throw(keyword_error);
 
1536
        }
 
1537
      writearg(m_readfilesinput.rg_timing_error);
 
1538
      }
 
1539
 
 
1540
// **********************************************************************
 
1541
    else if (!strcmp(keyword,"M_AZ_T_ERROR"))            // master timing error
 
1542
      {                                               
 
1543
       keyword = word[1];
 
1544
       char *pLast = NULL;
 
1545
       m_readfilesinput.az_timing_error = strtod( keyword, &pLast );
 
1546
       if ( pLast == keyword ) // fail
 
1547
        {
 
1548
          ERROR << "M_AZ_T_ERROR argument: "  << keyword << " is not valid.";
 
1549
          PRINT_ERROR(ERROR.get_str())
 
1550
          throw(keyword_error);
 
1551
        }
 
1552
      writearg(m_readfilesinput.az_timing_error);
 
1553
      }
 
1554
 
 
1555
// *******************************************************************
 
1556
    else if (!strcmp(keyword,"S_IN_METHOD"))         // ERS or ASAR ENVISAT
 
1557
      {                                               
 
1558
      keyword = word[1];
 
1559
      writearg(keyword);
 
1560
      toupper(keyword);
 
1561
 
 
1562
      if (!strcmp(keyword,"ERS"))
 
1563
        s_readfilesinput.sensor_id=SLC_ERS;         // default
 
1564
      else if (!strcmp(keyword,"ERS-1"))             // ers
 
1565
        s_readfilesinput.sensor_id=SLC_ERS;
 
1566
      else if (!strcmp(keyword,"ERS1"))              // ers
 
1567
        s_readfilesinput.sensor_id=SLC_ERS;
 
1568
      else if (!strcmp(keyword,"ERS-2"))             // ers
 
1569
        s_readfilesinput.sensor_id=SLC_ERS;
 
1570
      else if (!strcmp(keyword,"ERS2"))              // ers
 
1571
        s_readfilesinput.sensor_id=SLC_ERS;
 
1572
      else if (!strcmp(keyword,"ERS_N1"))           // ers in envisat file format [MA]; treat as ASAR
 
1573
        s_readfilesinput.sensor_id=SLC_ERS_N1;
 
1574
      else if (!strcmp(keyword,"N1"))                // envisat
 
1575
        s_readfilesinput.sensor_id=SLC_ASAR;
 
1576
      else if (!strcmp(keyword,"ASAR"))              // envisat
 
1577
        s_readfilesinput.sensor_id=SLC_ASAR;
 
1578
      else if (!strcmp(keyword,"ENVISAT"))           // envisat
 
1579
        s_readfilesinput.sensor_id=SLC_ASAR;
 
1580
      else if (!strcmp(keyword,"ATLANTIS"))          // radarsat ceos reader
 
1581
        s_readfilesinput.sensor_id=SLC_RSAT;
 
1582
      else if (!strcmp(keyword,"RSAT"))              // radarsat
 
1583
        s_readfilesinput.sensor_id=SLC_RSAT;
 
1584
      else if (!strcmp(keyword,"RADARSAT"))          // radarsat
 
1585
        s_readfilesinput.sensor_id=SLC_RSAT;
 
1586
      else if (!strcmp(keyword,"RADARSAT-1"))        // radarsat
 
1587
        s_readfilesinput.sensor_id=SLC_RSAT;
 
1588
      else if (!strcmp(keyword,"JERS"))              // jers
 
1589
        s_readfilesinput.sensor_id=SLC_JERS;
 
1590
      else if (!strcmp(keyword,"J-ERS"))             // jers
 
1591
        s_readfilesinput.sensor_id=SLC_JERS;
 
1592
      else if (!strcmp(keyword,"ALOS"))              // [DON]
 
1593
        s_readfilesinput.sensor_id=SLC_ALOS;
 
1594
      else if (!strcmp(keyword,"TSX"))               // TSX [PM]
 
1595
        s_readfilesinput.sensor_id=SLC_TSX;
 
1596
      else if (!strcmp(keyword,"TERRASARX"))         // TSX
 
1597
        s_readfilesinput.sensor_id=SLC_TSX;
 
1598
      else if (!strcmp(keyword,"TERRASAR-X"))        // TSX
 
1599
        s_readfilesinput.sensor_id=SLC_TSX;
 
1600
      else if (!strcmp(keyword,"RS2"))               // RS2  [MA]
 
1601
        s_readfilesinput.sensor_id=SLC_RS2;
 
1602
      else if (!strcmp(keyword,"RADARSAT-2"))        // RS2
 
1603
        s_readfilesinput.sensor_id=SLC_RS2;
 
1604
      else if (!strcmp(keyword,"CSK"))               // CSK  [PD]
 
1605
        s_readfilesinput.sensor_id=SLC_CSK;
 
1606
      else if (!strcmp(keyword,"CSX"))               // CSK  [PD]
 
1607
        s_readfilesinput.sensor_id=SLC_CSK;
 
1608
      else if (!strcmp(keyword,"GAMMA"))             // GAMMA [BO]
 
1609
        s_readfilesinput.sensor_id=SLC_GAMMA;        
 
1610
      else
 
1611
        {
 
1612
        ERROR << "S_IN_METHOD: method " <<  keyword
 
1613
             << " not known for reading input files on line "
 
1614
             << linecnt << ".";
 
1615
            PRINT_ERROR(ERROR.get_str())
 
1616
            throw(keyword_error);
 
1617
        }
 
1618
      }
 
1619
 
 
1620
// **********************************************************************
 
1621
    else if (!strcmp(keyword,"S_IN_VOL"))            // volumefile filename
 
1622
      {                                               
 
1623
      strcpy(s_readfilesinput.volfile, word[1]);          // pass keyword
 
1624
      writearg(s_readfilesinput.volfile);
 
1625
      }
 
1626
 
 
1627
// **********************************************************************
 
1628
    else if (!strcmp(keyword,"S_IN_LEA"))            // leaderfile filename
 
1629
      {                                               
 
1630
      strcpy(s_readfilesinput.leaderfile, word[1]);          // pass keyword
 
1631
      writearg(s_readfilesinput.leaderfile);
 
1632
      }
 
1633
 
 
1634
// **********************************************************************
 
1635
    else if (!strcmp(keyword,"S_IN_NULL"))           // nullfile filename
 
1636
      {                                               
 
1637
      strcpy(s_readfilesinput.nullfile, word[1]);          // pass keyword
 
1638
      writearg(s_readfilesinput.nullfile);
 
1639
      }
 
1640
 
 
1641
// **********************************************************************
 
1642
    else if (!strcmp(keyword,"S_IN_DAT"))            // datfile filename
 
1643
      {                                               
 
1644
      strcpy(s_readfilesinput.datfile, word[1]);          // pass keyword
 
1645
      writearg(s_readfilesinput.datfile);
 
1646
      }
 
1647
 
 
1648
// **********************************************************************
 
1649
    else if (!strcmp(keyword,"S_RG_T_ERROR"))            // slave timing error
 
1650
      {                                               
 
1651
       keyword = word[1];
 
1652
       char *pLast = NULL;
 
1653
       s_readfilesinput.rg_timing_error = strtod( keyword, &pLast );
 
1654
       if ( pLast == keyword ) // fail
 
1655
        {
 
1656
          ERROR << "S_RG_T_ERROR argument: "  << keyword << " is not valid.";
 
1657
          PRINT_ERROR(ERROR.get_str())
 
1658
          throw(keyword_error);
 
1659
        }
 
1660
      writearg(s_readfilesinput.rg_timing_error);
 
1661
      }
 
1662
 
 
1663
// **********************************************************************
 
1664
    else if (!strcmp(keyword,"S_AZ_T_ERROR"))            // slave timing error
 
1665
      {                                               
 
1666
       keyword = word[1];
 
1667
       char *pLast = NULL;
 
1668
       s_readfilesinput.az_timing_error = strtod( keyword, &pLast );
 
1669
       if ( pLast == keyword ) // fail
 
1670
        {
 
1671
          ERROR << "S_AZ_T_ERROR argument: "  << keyword << " is not valid.";
 
1672
          PRINT_ERROR(ERROR.get_str())
 
1673
          throw(keyword_error);
 
1674
        }
 
1675
      writearg(s_readfilesinput.az_timing_error);
 
1676
      }
 
1677
 
 
1678
 
 
1679
// **********************************************************************
 
1680
// *** ?_PORBITS
 
1681
// **********************************************************************
 
1682
    else if (!strcmp(keyword,"M_ORBDIR"))             // orbitfile filename
 
1683
      {                                               
 
1684
      if (specified(porbitsinput.m_orbdir))
 
1685
               WARNING.print("Prior occurence of M_ORBDIR ignored.");
 
1686
      strcpy(porbitsinput.m_orbdir,  word[1] );         // pass keyword
 
1687
      writearg(porbitsinput.m_orbdir);
 
1688
      }
 
1689
 
 
1690
// **********************************************************************
 
1691
    else if (!strcmp(keyword,"M_ORB_INTERVAL") ||      // time interval in sec
 
1692
                   !strcmp(keyword,"S_ORB_INTERVAL")) 
 
1693
      {                                               
 
1694
       keyword = word[1];         // pass keyword
 
1695
       char *pLast = NULL;
 
1696
       porbitsinput.timeinterval = strtol( keyword, &pLast , BASE10); // int32
 
1697
       if ( pLast == keyword ) // fail
 
1698
        {
 
1699
          ERROR << "[M|S]_ORB_INTERVAL argument: "  << keyword << " is not valid.";
 
1700
          PRINT_ERROR(ERROR.get_str())
 
1701
          throw(keyword_error);
 
1702
        }
 
1703
      writearg(porbitsinput.timeinterval);
 
1704
      }
 
1705
 
 
1706
// **********************************************************************
 
1707
    else if (!strcmp(keyword,"M_ORB_EXTRATIME") ||    // time before 1st line in sec
 
1708
             !strcmp(keyword,"S_ORB_EXTRATIME")) 
 
1709
      {                                               
 
1710
       keyword = word[1];         // pass keyword
 
1711
       char *pLast = NULL;
 
1712
       porbitsinput.timebefore = strtol( keyword, &pLast , BASE10); // int32 
 
1713
       if ( pLast == keyword ) // fail
 
1714
        {
 
1715
          ERROR << "[M|S]_ORB_EXTRATIME argument: "  << keyword << " is not valid.";
 
1716
          PRINT_ERROR(ERROR.get_str())
 
1717
          throw(keyword_error);
 
1718
        }
 
1719
      writearg(porbitsinput.timebefore);
 
1720
      }
 
1721
 
 
1722
// **********************************************************************
 
1723
    else if (!strcmp(keyword,"M_ORB_DUMP"))           // dump orbit with dt
 
1724
      {                                               
 
1725
       keyword = word[1];         // pass keyword
 
1726
       char *pLast = NULL;
 
1727
       porbitsinput.dumpmasterorbit = strtod( keyword, &pLast ); 
 
1728
       if ( pLast == keyword ) // fail
 
1729
        {
 
1730
          ERROR << "M_ORB_DUMP argument: "  << keyword << " is not valid.";
 
1731
          PRINT_ERROR(ERROR.get_str())
 
1732
          throw(keyword_error);
 
1733
        }
 
1734
      writearg(porbitsinput.dumpmasterorbit);
 
1735
      INFO.print("dumping master orbit to ascii file: masterorbit.dat");
 
1736
      }
 
1737
 
 
1738
// **********************************************************************
 
1739
    else if (!strcmp(keyword,"S_ORBDIR"))             // orbitfile filename
 
1740
      {                                               
 
1741
      if (specified(porbitsinput.s_orbdir))
 
1742
              WARNING.print("Prior occurence of S_ORBDIR ignored.");
 
1743
      strcpy(porbitsinput.s_orbdir,  word[1] );         // pass keyword
 
1744
      writearg(porbitsinput.s_orbdir);
 
1745
      }
 
1746
 
 
1747
// **********************************************************************
 
1748
    else if (!strcmp(keyword,"S_ORB_DUMP"))           // dump orbit with dt
 
1749
      {                                               
 
1750
       keyword = word[1];         // pass keyword
 
1751
       char *pLast = NULL;
 
1752
       porbitsinput.dumpslaveorbit = strtod( keyword, &pLast ); 
 
1753
       if ( pLast == keyword ) // fail
 
1754
        {
 
1755
          ERROR << "S_ORB_DUMP argument: "  << keyword << " is not valid.";
 
1756
          PRINT_ERROR(ERROR.get_str())
 
1757
          throw(keyword_error);
 
1758
        }
 
1759
      writearg(porbitsinput.dumpslaveorbit);
 
1760
      INFO.print("dumping slave orbit to ascii file: slaveorbit.dat");
 
1761
      }
 
1762
 
 
1763
 
 
1764
// ____ start added by HB ____
 
1765
// *******************************************************************
 
1766
// *** ?_MORBITS
 
1767
// *******************************************************************
 
1768
    else if (!strncmp(keyword,"M_MO_D",6))
 
1769
      {
 
1770
        char *keywordpart = &keyword[6];
 
1771
        int16 component;
 
1772
        if (!strncmp(keywordpart,"BH",2)) component = 0;
 
1773
        else if (!strncmp(keywordpart,"BV",2)) component = 1;
 
1774
        else
 
1775
          {
 
1776
            ERROR << "Unknown keyword: \"" << keyword << "\" at line: " << linecnt << ".";
 
1777
            PRINT_ERROR(ERROR.get_str()) throw(keyword_error);
 
1778
          }
 
1779
        int16 degree = int(keywordpart[2])-48; // char2int
 
1780
        morbitsinputmaster.coeff(degree,component) = atof(word[1]);
 
1781
        writearg(morbitsinputmaster.coeff(degree,component));
 
1782
      }
 
1783
 
 
1784
// *******************************************************************
 
1785
    else if (!strcmp(keyword,"M_MO_REFORBIT"))
 
1786
      {
 
1787
        strcpy(morbitsinputmaster.reforbitfile, word[1]);
 
1788
        writearg(morbitsinputmaster.reforbitfile);
 
1789
      }
 
1790
 
 
1791
// *******************************************************************
 
1792
    else if (!strncmp(keyword,"S_MO_D",6))
 
1793
      {
 
1794
        char *keywordpart = &keyword[6];
 
1795
        int16 component;
 
1796
        if (!strncmp(keywordpart,"BH",2)) component = 0;
 
1797
        else if (!strncmp(keywordpart,"BV",2)) component = 1;
 
1798
        else
 
1799
          {
 
1800
            ERROR << "Unknown keyword: \"" << keyword << "\" at line: " << linecnt << ".";
 
1801
            PRINT_ERROR(ERROR.get_str()) throw(keyword_error);
 
1802
          }
 
1803
        int16 degree = int(keywordpart[2])-48; // char2int
 
1804
        morbitsinputslave.coeff(degree,component) = atof(word[1]);
 
1805
        writearg(morbitsinputslave.coeff(degree,component));
 
1806
      }
 
1807
 
 
1808
// *******************************************************************
 
1809
    else if (!strcmp(keyword,"S_MO_REFORBIT"))
 
1810
      {
 
1811
        strcpy(morbitsinputslave.reforbitfile, word[1]);
 
1812
        writearg(morbitsinputslave.reforbitfile);
 
1813
      }
 
1814
// ____ end added by HB ____
 
1815
    
 
1816
 
 
1817
// *******************************************************************
 
1818
// *** ?_CROP
 
1819
// *******************************************************************
 
1820
    else if (!strcmp(keyword,"M_CROP_ID"))          // identifier of run
 
1821
      {                                               
 
1822
      strcpy(m_cropinput.idcrop,  word[1] );    // pass keyword
 
1823
      writearg(m_cropinput.idcrop);
 
1824
      }
 
1825
 
 
1826
// *******************************************************************   CROP
 
1827
    else if (!strcmp(keyword,"S_CROP_ID"))          // identifier of run
 
1828
      {                                               
 
1829
      strcpy(s_cropinput.idcrop,  word[1] );    // pass keyword
 
1830
      writearg(s_cropinput.idcrop);
 
1831
      }
 
1832
 
 
1833
// **********************************************************************
 
1834
    else if (!strcmp(keyword,"M_CROP_IN"))              // SLC input image filename
 
1835
      {                                               
 
1836
      strcpy(m_cropinput.filein1,  word[1] );   // pass keyword
 
1837
      writearg(m_cropinput.filein1);
 
1838
      }
 
1839
 
 
1840
// **********************************************************************
 
1841
    else if (!strcmp(keyword,"S_CROP_IN"))              // SLC input image filename
 
1842
      {                                               
 
1843
      strcpy(s_cropinput.filein1,  word[1] );   // pass keyword
 
1844
      writearg(s_cropinput.filein1);
 
1845
      }
 
1846
 
 
1847
// **********************************************************************
 
1848
    else if (!strcmp(keyword,"M_CROP_OUT"))             // SLC output image filename
 
1849
      {                                               
 
1850
      strcpy(m_cropinput.fileout1,  word[1] );  // pass keyword
 
1851
      writearg(m_cropinput.fileout1);
 
1852
      }
 
1853
 
 
1854
// **********************************************************************
 
1855
    else if (!strcmp(keyword,"S_CROP_OUT"))             // SLC output image filename
 
1856
      {                                               
 
1857
      strcpy(s_cropinput.fileout1,  word[1] );  // pass keyword
 
1858
      writearg(s_cropinput.fileout1);
 
1859
      }
 
1860
 
 
1861
// **********************************************************************
 
1862
    else if (!strcmp(keyword,"M_DBOW"))               // min. line coord.
 
1863
      {                                               
 
1864
       m_cropinput.dbow.linelo = atoi(word[1]);  // pass keywords
 
1865
       m_cropinput.dbow.linehi = atoi(word[2]);
 
1866
       m_cropinput.dbow.pixlo  = atoi(word[3]);
 
1867
       m_cropinput.dbow.pixhi  = atoi(word[4]);
 
1868
 
 
1869
      writearg(m_cropinput.dbow.linelo);
 
1870
      writearg(m_cropinput.dbow.linehi);
 
1871
      writearg(m_cropinput.dbow.pixlo);
 
1872
      writearg(m_cropinput.dbow.pixhi);
 
1873
 
 
1874
// ______initial check, later checked to #lines of image______
 
1875
      if (m_cropinput.dbow.linelo <= 0 || 
 
1876
          m_cropinput.dbow.pixlo <= 0 ||
 
1877
          m_cropinput.dbow.linelo  > m_cropinput.dbow.linehi ||
 
1878
          m_cropinput.dbow.pixlo > m_cropinput.dbow.pixhi)
 
1879
        {
 
1880
        ERROR << "code 300: Arguments of M_DBOW card on line " << linecnt
 
1881
             << " missing. [DBOW  min_line  max_line  min_pixel  max_pixel].";
 
1882
        PRINT_ERROR(ERROR.get_str())
 
1883
        throw(keyword_error);
 
1884
        }
 
1885
      }
 
1886
 
 
1887
// **********************************************************************
 
1888
    else if (!strcmp(keyword,"S_DBOW"))               // min. line coord.
 
1889
      {                                               
 
1890
       s_cropinput.dbow.linelo = atoi(word[1]);  // pass keywords
 
1891
       s_cropinput.dbow.linehi = atoi(word[2]);
 
1892
       s_cropinput.dbow.pixlo  = atoi(word[3]);
 
1893
       s_cropinput.dbow.pixhi  = atoi(word[4]);
 
1894
 
 
1895
      writearg(s_cropinput.dbow.linelo);
 
1896
      writearg(s_cropinput.dbow.linehi);
 
1897
      writearg(s_cropinput.dbow.pixlo);
 
1898
      writearg(s_cropinput.dbow.pixhi);
 
1899
      // ______initial check, later checked to #lines of image______
 
1900
      if (s_cropinput.dbow.linelo <= 0 || 
 
1901
          s_cropinput.dbow.pixlo <= 0 ||
 
1902
          s_cropinput.dbow.linelo  > s_cropinput.dbow.linehi ||
 
1903
          s_cropinput.dbow.pixlo > s_cropinput.dbow.pixhi)
 
1904
        {
 
1905
        ERROR << "code 300: Arguments of S_DBOW card on line " << linecnt
 
1906
             << " missing. [DBOW  min_line  max_line  min_pixel  max_pixel].";
 
1907
        PRINT_ERROR(ERROR.get_str())
 
1908
        throw(keyword_error);
 
1909
        }
 
1910
      }
 
1911
 
 
1912
// **********************************************************************
 
1913
    // BK 15-Dec-2003
 
1914
    else if (!strcmp(keyword,"M_DBOW_GEO")) // 1e6*lat_0 [deg], lon_0, height, width [pix]
 
1915
      {                                               
 
1916
      // use dbow to store tmp, compute later in crop if not zero
 
1917
      real8 tmp_lat_0, tmp_lon_0, tmp_height, tmp_width;
 
1918
      tmp_lat_0  =  atof(word[1]) ;     // pass keyword
 
1919
      tmp_lon_0  =  atof(word[2]) ;     // pass keyword
 
1920
      tmp_height =  atof(word[3]) ;     // pass keyword
 
1921
       tmp_width =  atof(word[4]) ;     // pass keyword
 
1922
      writearg(tmp_lat_0);
 
1923
      writearg(tmp_lon_0);
 
1924
      writearg(tmp_height);
 
1925
      writearg(tmp_width);
 
1926
      m_cropinput.dbow_geo.linelo = uint((360.0+tmp_lat_0)*1e6);
 
1927
      m_cropinput.dbow_geo.linehi = uint((360.0+tmp_lon_0)*1e6);
 
1928
      m_cropinput.dbow_geo.pixlo  = uint(tmp_height);
 
1929
      m_cropinput.dbow_geo.pixhi  = uint(tmp_width);
 
1930
      }
 
1931
 
 
1932
// **********************************************************************
 
1933
    // BK 15-Dec-2003
 
1934
    else if (!strcmp(keyword,"S_DBOW_GEO")) // 1e6*lat_0 [deg], lon_0, height, width [pix]
 
1935
      {                                               
 
1936
      // use dbow to store tmp, compute later in crop if not zero
 
1937
      real8 tmp_lat_0, tmp_lon_0, tmp_height, tmp_width;
 
1938
      tmp_lat_0  =  atof(word[1]) ;     // pass keyword
 
1939
      tmp_lon_0  =  atof(word[2]) ;     // pass keyword
 
1940
      tmp_height =  atof(word[3]) ;     // pass keyword
 
1941
       tmp_width =  atof(word[4]) ;     // pass keyword
 
1942
      writearg(tmp_lat_0);
 
1943
      writearg(tmp_lon_0);
 
1944
      writearg(tmp_height);
 
1945
      writearg(tmp_width);
 
1946
      s_cropinput.dbow_geo.linelo = uint((360.0+tmp_lat_0)*1e6);
 
1947
      s_cropinput.dbow_geo.linehi = uint((360.0+tmp_lon_0)*1e6);
 
1948
      s_cropinput.dbow_geo.pixlo  = uint(tmp_height);
 
1949
      s_cropinput.dbow_geo.pixhi  = uint(tmp_width);
 
1950
      }
 
1951
 
 
1952
//____RaffaeleNutricato START MODIFICATION SECTION 9
 
1953
// *******************************************************************
 
1954
// *** ?_OVS
 
1955
// **********************************************************************
 
1956
    else if (!strcmp(keyword,"M_OVS_OUT"))             // oversampled SLC output image filename
 
1957
      {                                               
 
1958
      strcpy(m_oversample.fileoutovs,  word[1] );       // pass keyword
 
1959
      writearg(m_oversample.fileoutovs);
 
1960
      }
 
1961
 
 
1962
// **********************************************************************
 
1963
    else if (!strcmp(keyword,"S_OVS_OUT"))             // oversampled SLC output image filename
 
1964
      {                                               
 
1965
      strcpy(s_oversample.fileoutovs,  word[1] );       // pass keyword
 
1966
      writearg(s_oversample.fileoutovs);
 
1967
      }
 
1968
 
 
1969
// *******************************************************************
 
1970
    else if (!strcmp(keyword,"M_OVS_FACT_RNG"))               // Oversampling ratio in the master range direction.
 
1971
      {                                                  
 
1972
      m_oversample.OsrRange =  strtol(word[1],NULL, BASE10);      // pass keyword               
 
1973
      writearg(m_oversample.OsrRange);                    
 
1974
      if (m_oversample.OsrRange < 1)
 
1975
              {
 
1976
        PRINT_ERROR(
 
1977
        "(M_OVS_FACT_RNG < 1) Oversampling ratio must be at least 1.");
 
1978
              throw(keyword_error);
 
1979
              }
 
1980
      }                                                  
 
1981
 
 
1982
// ********************************************************************** 
 
1983
    else if (!strcmp(keyword,"S_OVS_FACT_RNG"))               // Oversampling ratio in the slave range direction.
 
1984
      {                                                       
 
1985
      s_oversample.OsrRange =  strtol(word[1],NULL, BASE10) ;  // pass keyword               
 
1986
      writearg(s_oversample.OsrRange);                    
 
1987
      if (s_oversample.OsrRange < 1)
 
1988
        {
 
1989
        PRINT_ERROR(
 
1990
        "(S_OVS_FACT_RNG < 1) Oversampling ratio must be at least 1.");
 
1991
        throw(keyword_error);
 
1992
        }
 
1993
      }                                                  
 
1994
 
 
1995
// *******************************************************************
 
1996
    else if (!strcmp(keyword,"M_OVS_FACT_AZI"))               // Oversampling ratio in the master azimuth direction.
 
1997
      {                                                  
 
1998
      m_oversample.OsrAzimuth = strtol(word[1],NULL, BASE10) ;         // pass keyword               
 
1999
      writearg(m_oversample.OsrAzimuth);                    
 
2000
      if (m_oversample.OsrAzimuth < 1)
 
2001
        {
 
2002
        PRINT_ERROR(
 
2003
        "(M_OVS_FACT_AZI < 1) Oversampling ratio must be at least 1.");
 
2004
        throw(keyword_error);
 
2005
        }
 
2006
      if (m_oversample.OsrAzimuth > 2)
 
2007
        {
 
2008
        PRINT_ERROR(
 
2009
        "(M_OVS_FACT_AZI > 2) Not implemented!");
 
2010
        throw(keyword_error);
 
2011
        }
 
2012
      }                                                  
 
2013
 
 
2014
// ********************************************************************** 
 
2015
    else if (!strcmp(keyword,"S_OVS_FACT_AZI"))               // Oversampling ratio in the slave azimuth direction.
 
2016
      {                                                       
 
2017
      s_oversample.OsrAzimuth =  strtol(word[1],NULL, BASE10) ;        // pass keyword               
 
2018
      writearg(s_oversample.OsrAzimuth);                    
 
2019
      if (s_oversample.OsrAzimuth < 1)
 
2020
        {
 
2021
        PRINT_ERROR("(S_OVS_FACT_AZI < 1) Oversampling ratio must be at least 1.");
 
2022
        throw(keyword_error);
 
2023
        }
 
2024
      if (s_oversample.OsrAzimuth > 2)
 
2025
        {
 
2026
        PRINT_ERROR(
 
2027
        "(S_OVS_FACT_AZI > 2) Not implemented!");
 
2028
        throw(keyword_error);
 
2029
        }
 
2030
      }                                                  
 
2031
 
 
2032
// ********************************************************************** 
 
2033
    else if (!strcmp(keyword,"M_OVS_KERNELSIZE"))     // Length of the interpolation kernel. 
 
2034
      {                                                  
 
2035
      m_oversample.FilterSize =  strtol(word[1],NULL, BASE10) ;        // pass keyword        
 
2036
      writearg(m_oversample.FilterSize);             
 
2037
      if (m_oversample.FilterSize < 2)
 
2038
        {
 
2039
         PRINT_ERROR("(M_OVS_KERNELSIZE < 2) Interpolation kernel length must be > 1.");
 
2040
        throw(keyword_error);
 
2041
        }
 
2042
      if (m_oversample.FilterSize % 2)
 
2043
        {
 
2044
        PRINT_ERROR("(M_OVS_KERNELSIZE not even) Range Interpolation kernel length must be an even number.");
 
2045
        throw(keyword_error);
 
2046
        }
 
2047
      }                                                  
 
2048
 
 
2049
// ********************************************************************** 
 
2050
    else if (!strcmp(keyword,"S_OVS_KERNELSIZE"))     // Length of the interpolation kernel. 
 
2051
      {                                                  
 
2052
      s_oversample.FilterSize =  strtol(word[1],NULL, BASE10) ;        // pass keyword        
 
2053
      writearg(s_oversample.FilterSize);             
 
2054
      if (s_oversample.FilterSize < 2)
 
2055
        {
 
2056
        PRINT_ERROR("code ???: (S_OVS_KERNELSIZE < 2) Interpolation kernel length must be > 1.");
 
2057
        throw(keyword_error);
 
2058
        }
 
2059
      if (s_oversample.FilterSize % 2)
 
2060
        {
 
2061
        PRINT_ERROR(
 
2062
        "code ???: (S_OVS_KERNELSIZE not even) Interpolation kernel length must be an even number.");
 
2063
        throw(keyword_error);
 
2064
        }
 
2065
      }                                                  
 
2066
 
 
2067
// ********************************************************************** 
 
2068
    else if (!strcmp(keyword,"M_OVS_OUT_FORMAT"))         // Output format [cr4] ci16, I suggest [cr4].
 
2069
      {                                                  
 
2070
      keyword =  word[1] ;      // pass keyword                           
 
2071
      writearg(keyword);
 
2072
      toupper(keyword);
 
2073
      if (!strcmp(keyword,"CR4"))
 
2074
        m_oversample.oformatflag = FORMATCR4;         // default
 
2075
      else if (!strcmp(keyword,"CI2"))
 
2076
        m_oversample.oformatflag = FORMATCI2;
 
2077
      else
 
2078
        {  
 
2079
        ERROR << "M_OVS_OUT_FORMAT: output format "
 
2080
             <<  keyword
 
2081
             << " not known for master range oversampling. line "
 
2082
             << linecnt << ".";
 
2083
          PRINT_ERROR(ERROR.get_str())      
 
2084
        throw(keyword_error);
 
2085
        }             
 
2086
      }                                                  
 
2087
 
 
2088
// ********************************************************************** 
 
2089
    else if (!strcmp(keyword,"S_OVS_OUT_FORMAT"))         // Output format [cr4] ci16, I suggest [cr4].
 
2090
      {                                                  
 
2091
      keyword =  word[1] ;      // pass keyword                           
 
2092
      writearg(keyword);
 
2093
      toupper(keyword);
 
2094
      if (!strcmp(keyword,"CR4"))
 
2095
        s_oversample.oformatflag = FORMATCR4;         // default
 
2096
      else if (!strcmp(keyword,"CI2"))
 
2097
        s_oversample.oformatflag = FORMATCI2;
 
2098
      else
 
2099
        {  
 
2100
        ERROR << "S_OVS_OUT_FORMAT: output format "
 
2101
             <<  keyword
 
2102
             << " not known for slave range oversampling. line "
 
2103
             << linecnt << ".";
 
2104
          PRINT_ERROR(ERROR.get_str()) 
 
2105
        throw(keyword_error);
 
2106
        }             
 
2107
      }               
 
2108
//____RaffaeleNutricato END MODIFICATION SECTION 9
 
2109
 
 
2110
// ____ start added by MA ____
 
2111
 
 
2112
 
 
2113
// **********************************************************************
 
2114
// *** SIMULATE AMPLITUDE FOR MASTER
 
2115
// **********************************************************************
 
2116
 
 
2117
      else if (!strcmp(keyword,"SAM_IN_DEM") && 
 
2118
                 (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )          // input file
 
2119
                                                                                                 // [MA] read parm only if there is (ONLY)PROCESS flag
 
2120
                                                                                                 // default onlyprocess is -1
 
2121
      {
 
2122
      strcpy(simampinput.firefdem,  word[1] );  // pass keyword
 
2123
      writearg(simampinput.firefdem);
 
2124
      }
 
2125
 
 
2126
// **********************************************************************
 
2127
    else if (!strcmp(keyword,"SAM_IN_FORMAT") && 
 
2128
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )       //  format input file
 
2129
      {
 
2130
      keyword =  word[1] ;      // pass keyword
 
2131
      writearg(keyword);
 
2132
      toupper(keyword);
 
2133
      if (!strcmp(keyword,"R4") || !strcmp(keyword,"REAL4"))
 
2134
        simampinput.iformatflag = FORMATR4;
 
2135
      else if (!strcmp(keyword,"I2") || !strcmp(keyword,"SHORT"))
 
2136
        simampinput.iformatflag = FORMATI2;     // default
 
2137
      else if (!strcmp(keyword,"I2_BIGENDIAN") || 
 
2138
               !strcmp(keyword,"SHORT_BIGENDIAN"))
 
2139
        simampinput.iformatflag = FORMATI2_BIGENDIAN;   // default
 
2140
      else if (!strcmp(keyword,"R8") || !strcmp(keyword,"REAL8"))
 
2141
        simampinput.iformatflag = FORMATR8;
 
2142
      else
 
2143
        {
 
2144
        ERROR << "SAM_IN_FORMAT: input format "
 
2145
             <<  keyword
 
2146
             << " not known (R4 R8 I2 (native) SHORT_BIGENDIAN); line "
 
2147
             << linecnt << ".";
 
2148
              PRINT_ERROR(ERROR.get_str())
 
2149
              throw(keyword_error);
 
2150
        }
 
2151
      }
 
2152
 
 
2153
// **********************************************************************
 
2154
    else if (!strcmp(keyword,"SAM_IN_SIZE") &&
 
2155
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )         // nrow ncols (lat lon)
 
2156
      {
 
2157
      char *pLast1, *pLast2 = NULL;
 
2158
      simampinput.demrows = strtoul(word[1], &pLast1, BASE10); 
 
2159
      simampinput.demcols = strtoul(word[2], &pLast2, BASE10);
 
2160
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
2161
       {
 
2162
        ERROR << "SAM_IN_SIZE: "  << word[1] << " : " 
 
2163
              << word[2] << " are not valid.";
 
2164
        PRINT_ERROR(ERROR.get_str())
 
2165
        throw(keyword_error);
 
2166
       }
 
2167
      writearg(simampinput.demrows);
 
2168
      writearg(simampinput.demcols);
 
2169
      }
 
2170
 
 
2171
// **********************************************************************
 
2172
    else if (!strcmp(keyword,"SAM_IN_DELTA") && 
 
2173
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )        // degrees delta lat lon
 
2174
      {
 
2175
      simampinput.demdeltalat  = atof(word[1]);           // pass keyword
 
2176
      keyword                  =  word[2];              // pass keyword
 
2177
      writearg(simampinput.demdeltalat);
 
2178
      writearg(keyword);
 
2179
      if (isdigit(keyword[0]) || keyword[0]=='.')    // likely to be 2 numbers
 
2180
        simampinput.demdeltalon = atof(keyword);
 
2181
      else // default same gridsize
 
2182
        simampinput.demdeltalon = simampinput.demdeltalat;
 
2183
 
 
2184
      // ______ Store as radians ______
 
2185
      simampinput.demdeltalat = deg2rad(simampinput.demdeltalat);
 
2186
      simampinput.demdeltalon = deg2rad(simampinput.demdeltalon);
 
2187
      }
 
2188
 
 
2189
// **********************************************************************
 
2190
    else if (!strcmp(keyword,"SAM_IN_UL")  && 
 
2191
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )           // upperleft coordinates
 
2192
      {
 
2193
      char *pLast1, *pLast2 = NULL;
 
2194
      simampinput.demlatleftupper = strtod(word[1], &pLast1); 
 
2195
      simampinput.demlonleftupper = strtod(word[2], &pLast2);
 
2196
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
2197
       {
 
2198
        ERROR << "SAM_IN_UL: "  << word[1] << " : " 
 
2199
              << word[2] << " are not valid.";
 
2200
        PRINT_ERROR(ERROR.get_str())
 
2201
        throw(keyword_error);
 
2202
       }
 
2203
      writearg(simampinput.demlatleftupper);
 
2204
      writearg(simampinput.demlonleftupper);
 
2205
      simampinput.demlatleftupper = deg2rad(simampinput.demlatleftupper);
 
2206
      simampinput.demlonleftupper = deg2rad(simampinput.demlonleftupper);
 
2207
      }
 
2208
 
 
2209
// **********************************************************************
 
2210
    else if (!strcmp(keyword,"SAM_IN_NODATA")  &&
 
2211
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )       // flag for no data
 
2212
      {
 
2213
      char *pLast = NULL;
 
2214
      simampinput.demnodata = strtod(word[1], &pLast); 
 
2215
      if ( pLast == word[1]  ) // fails to convert to double.
 
2216
       {
 
2217
        ERROR << "SAM_IN_NODATA: "  << word[1] << " is not valid.";
 
2218
        PRINT_ERROR(ERROR.get_str())
 
2219
        throw(keyword_error);
 
2220
       }
 
2221
      writearg(simampinput.demnodata);
 
2222
      }
 
2223
 
 
2224
// **********************************************************************
 
2225
    else if (!strcmp(keyword,"SAM_OUT_DEM")  &&
 
2226
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )          // name of output file
 
2227
      {
 
2228
      strcpy(simampinput.fodem,  word[1] );     // pass keyword
 
2229
      writearg(simampinput.fodem);
 
2230
      }
 
2231
 
 
2232
// **********************************************************************
 
2233
    else if (!strcmp(keyword,"SAM_OUT_FILE") &&  
 
2234
               (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )          // name of output file
 
2235
      {
 
2236
      strcpy(simampinput.fosimamp,  word[1] );  // pass keyword
 
2237
      writearg(simampinput.fosimamp);
 
2238
      }
 
2239
 
 
2240
// // **********************************************************************
 
2241
//     else if (!strcmp(keyword,"SAM_OUT_DEMI"))          // name of output file
 
2242
//       {
 
2243
//       strcpy(demassistinput.fodemi,  word[1] );      // pass keyword
 
2244
//       writearg(demassistinput.fodemi);
 
2245
//       }
 
2246
// 
 
2247
// // **********************************************************************
 
2248
     else if (!strcmp(keyword,"SAM_OUT_DEM_LP") && 
 
2249
                (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )        // name of output file  // MA enabled for SPT tracking.
 
2250
       {
 
2251
       strcpy(simampinput.fodemlp,  word[1] );         // pass keyword
 
2252
       writearg(simampinput.fodemlp);
 
2253
       }
 
2254
     else if (!strcmp(keyword,"SAM_OUT_THETA_LP") && 
 
2255
                (  generalinput.process[pr_m_simamp] || onlyprocess == pr_m_simamp ) )        // name of output file  // MA enabled for SPT tracking.
 
2256
       {
 
2257
       strcpy(simampinput.fothetalp,  word[1] );         // pass keyword
 
2258
       writearg(simampinput.fothetalp);
 
2259
       }
 
2260
 
 
2261
 
 
2262
// **********************************************************************
 
2263
// *** MASTER TIMING ERROR ESTIMATION using COREGISTRATION                             
 
2264
// **********************************************************************
 
2265
    else if (!strcmp(keyword,"MTE_METHOD"))            // method selector simamp coreg
 
2266
      {                                               
 
2267
      keyword =  word[1] ;      // pass keyword
 
2268
      writearg(keyword);
 
2269
      toupper(keyword);
 
2270
      if (!strcmp(keyword,"MAGFFT"))
 
2271
        {
 
2272
         mtiminginput.method=cc_magfft;                // default MTE_magfft
 
2273
        }
 
2274
      else if (!strcmp(keyword,"MAGSPACE"))
 
2275
        {
 
2276
         mtiminginput.method=cc_magspace;              // MTE_magspace
 
2277
        }
 
2278
      else
 
2279
        {
 
2280
         ERROR << "MTE_METHOD: method " <<  keyword
 
2281
               << " not known for simamp correlation coregistration on line "
 
2282
               << linecnt << ".";
 
2283
         PRINT_ERROR(ERROR.get_str())
 
2284
               throw(keyword_error);
 
2285
        }
 
2286
      }
 
2287
 
 
2288
// **********************************************************************
 
2289
    else if (!strcmp(keyword,"MTE_NWIN"))              // #windows for simamp correlation
 
2290
      {                                               
 
2291
      char *pLast = NULL;
 
2292
      mtiminginput.Nwin = strtoul(word[1], &pLast, BASE10); 
 
2293
      if ( pLast == word[1]  ) // fails to convert to double.
 
2294
       {
 
2295
        ERROR << "MTE_NWIN: "  << word[1] << " is not valid.";
 
2296
        PRINT_ERROR(ERROR.get_str())
 
2297
        throw(keyword_error);
 
2298
       }
 
2299
      writearg(mtiminginput.Nwin);
 
2300
      if (mtiminginput.Nwin > 10000)
 
2301
             {
 
2302
        PRINT_ERROR("Too many windows requested (MTE_NWIN > 10000).")
 
2303
        throw(keyword_error);
 
2304
             }
 
2305
      }
 
2306
 
 
2307
// **********************************************************************
 
2308
    else if (!strcmp(keyword,"MTE_IN_POS"))            // file with #windows positions
 
2309
      {                                               
 
2310
      strcpy(mtiminginput.ifpositions,  word[1] );      // pass keyword
 
2311
      writearg(mtiminginput.ifpositions);
 
2312
      }
 
2313
 
 
2314
// **********************************************************************
 
2315
    else if (!strcmp(keyword,"MTE_WINSIZE"))           // windowsize for simamp correlation
 
2316
      {                                               
 
2317
      char *pLast1, *pLast2 = NULL;
 
2318
      mtiminginput.MasksizeL = strtoul(word[1], &pLast1, BASE10); 
 
2319
      mtiminginput.MasksizeP = strtoul(word[2], &pLast2, BASE10);
 
2320
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
2321
       {
 
2322
        ERROR << "MTE_WINSIZE: "  << word[1] << " : " 
 
2323
              << word[2] << " are not valid.";
 
2324
        PRINT_ERROR(ERROR.get_str())
 
2325
        throw(keyword_error);
 
2326
       }
 
2327
      writearg(mtiminginput.MasksizeL);
 
2328
      writearg(mtiminginput.MasksizeP);
 
2329
      if (mtiminginput.MasksizeL > 4096 || mtiminginput.MasksizeP > 4096)
 
2330
              {
 
2331
        PRINT_ERROR("Too large correlation window (MTE_WINSIZE > 4096).");
 
2332
        throw(keyword_error);
 
2333
              }
 
2334
      }
 
2335
 
 
2336
// **********************************************************************
 
2337
    else if (!strcmp(keyword,"MTE_ACC"))               // Searchdomain for correlation
 
2338
      {                                               //  simamp correlation
 
2339
      char *pLast1, *pLast2 = NULL;
 
2340
      mtiminginput.AccL  = strtoul(word[1], &pLast1, BASE10); 
 
2341
      mtiminginput.AccP  = strtoul(word[2], &pLast2, BASE10);
 
2342
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
2343
       {
 
2344
        ERROR << "MTE_ACC: "  << word[1] << " : " 
 
2345
              << word[2] << " are not valid.";
 
2346
        PRINT_ERROR(ERROR.get_str())
 
2347
        throw(keyword_error);
 
2348
       }
 
2349
      writearg(mtiminginput.AccL);
 
2350
      writearg(mtiminginput.AccP);
 
2351
      if (mtiminginput.AccL > 1000 || mtiminginput.AccP > 1000)
 
2352
              {
 
2353
        PRINT_ERROR("Too large searchwindow (MTE_ACC > 1000).");
 
2354
        throw(keyword_error);
 
2355
              }
 
2356
      if (mtiminginput.AccL == 0 || mtiminginput.AccP == 0)
 
2357
              {
 
2358
        PRINT_ERROR("Acc = 0 ?(MTE_ACC).");
 
2359
        throw(keyword_error);
 
2360
              }
 
2361
      }
 
2362
 
 
2363
// **********************************************************************
 
2364
    else if (!strcmp(keyword,"MTE_INITOFF"))            // Initial offset
 
2365
      {
 
2366
      keyword   =  word[1] ;    // pass keyword
 
2367
      char *keyword2  =  word[2] ;      // pass keyword
 
2368
      writearg(keyword);
 
2369
      writearg(keyword2);
 
2370
      if (isdigit(keyword2[0]) || keyword2[0]=='-') // likely to be 2 numbers
 
2371
                                                    // BK19/1/00 thanks to m.goos for '-'
 
2372
        {
 
2373
        mtiminginput.initoffsetL = atoi(keyword);
 
2374
        mtiminginput.initoffsetP = atoi(keyword2);
 
2375
        }
 
2376
      else
 
2377
        {
 
2378
        ERROR << "MTE_INITOFF: unknown input: "
 
2379
             <<  keyword << ", " << keyword2
 
2380
             << " on line "
 
2381
             << linecnt << ".";
 
2382
        PRINT_ERROR(ERROR.get_str())
 
2383
        throw(keyword_error);
 
2384
        }
 
2385
      }
 
2386
 
 
2387
 
 
2388
// ____ end added by MA ____
 
2389
 
 
2390
 
 
2391
// **********************************************************************
 
2392
// *** AZIMUTH FILTERING
 
2393
// **********************************************************************
 
2394
    else if (!strcmp(keyword,"AF_BLOCKSIZE"))
 
2395
      {
 
2396
      char *pLast = NULL;
 
2397
      filtaziinput.fftlength = strtol(word[1], &pLast, BASE10); // int32 
 
2398
      if ( pLast == word[1]  ) // fails to convert to double.
 
2399
       {
 
2400
        ERROR << "AF_BLOCKSIZE: "  << word[1] << " is not valid.";
 
2401
        PRINT_ERROR(ERROR.get_str())
 
2402
        throw(keyword_error);
 
2403
       }
 
2404
      writearg(filtaziinput.fftlength);
 
2405
      }
 
2406
 
 
2407
// **********************************************************************
 
2408
    else if (!strcmp(keyword,"AF_HAMMING"))
 
2409
      {
 
2410
      char *pLast = NULL;
 
2411
      filtaziinput.hammingalpha = strtod(word[1], &pLast); 
 
2412
      if ( pLast == word[1]  ) // fails to convert to double.
 
2413
       {
 
2414
        ERROR << "AF_HAMMING: "  << word[1] << " is not valid.";
 
2415
        PRINT_ERROR(ERROR.get_str())
 
2416
        throw(keyword_error);
 
2417
       }
 
2418
      writearg(filtaziinput.hammingalpha);
 
2419
      }
 
2420
 
 
2421
// **********************************************************************
 
2422
    else if (!strcmp(keyword,"AF_OVERLAP"))
 
2423
      {
 
2424
      char *pLast = NULL;
 
2425
      filtaziinput.overlap = strtol(word[1], &pLast, BASE10); // int32 
 
2426
      if ( pLast == word[1]  ) // fails to convert to double.
 
2427
       {
 
2428
        ERROR << "AF_OVERLAP: "  << word[1] << " is not valid.";
 
2429
        PRINT_ERROR(ERROR.get_str())
 
2430
        throw(keyword_error);
 
2431
       }
 
2432
      writearg(filtaziinput.overlap);
 
2433
      }
 
2434
 
 
2435
// **********************************************************************
 
2436
    else if (!strcmp(keyword,"AF_OUT_MASTER"))
 
2437
      {
 
2438
      strcpy(filtaziinput.fomaster,  word[1] );         // pass keyword
 
2439
      writearg(filtaziinput.fomaster);
 
2440
      }
 
2441
 
 
2442
// **********************************************************************
 
2443
    else if (!strcmp(keyword,"AF_OUT_SLAVE"))
 
2444
      {
 
2445
      strcpy(filtaziinput.foslave,  word[1] );  // pass keyword
 
2446
      writearg(filtaziinput.foslave);
 
2447
      }
 
2448
 
 
2449
// **********************************************************************
 
2450
    else if (!strcmp(keyword,"AF_OUT_FORMAT"))          // output format
 
2451
      {
 
2452
      keyword =  word[1] ;      // pass keyword
 
2453
      writearg(keyword);
 
2454
      toupper(keyword);
 
2455
      if (!strcmp(keyword,"CR4"))
 
2456
        filtaziinput.oformatflag = FORMATCR4;         // default
 
2457
      else if (!strcmp(keyword,"CI2"))
 
2458
        filtaziinput.oformatflag = FORMATCI2;
 
2459
      else
 
2460
        {
 
2461
        ERROR << "AF_OUT_FORMAT: output format "
 
2462
             <<  keyword
 
2463
             << " not known for azimuth filtering. line "
 
2464
             << linecnt << ".";
 
2465
              PRINT_ERROR(ERROR.get_str())
 
2466
              throw(keyword_error);
 
2467
        }
 
2468
      }
 
2469
 
 
2470
 
 
2471
 
 
2472
// **********************************************************************
 
2473
// *** COARSE CORR COREGISTRATION
 
2474
// **********************************************************************
 
2475
    else if (!strcmp(keyword,"CC_METHOD"))            // method selector coarse coreg
 
2476
      {                                               
 
2477
      keyword =  word[1] ;      // pass keyword
 
2478
      writearg(keyword);
 
2479
      toupper(keyword);
 
2480
      if (!strcmp(keyword,"MAGFFT"))
 
2481
        coarsecorrinput.method=cc_magfft;             // default
 
2482
      else if (!strcmp(keyword,"MAGSPACE"))
 
2483
        coarsecorrinput.method=cc_magspace;
 
2484
      else
 
2485
        {
 
2486
        ERROR << "CC_METHOD: method " <<  keyword
 
2487
             << " not known for coarse correlation coregistration on line "
 
2488
             << linecnt << ".";
 
2489
              PRINT_ERROR(ERROR.get_str())
 
2490
              throw(keyword_error);
 
2491
        }
 
2492
      }
 
2493
 
 
2494
// **********************************************************************
 
2495
    else if (!strcmp(keyword,"CC_NWIN"))              // #windows for coarse correlation
 
2496
      {                                               
 
2497
      coarsecorrinput.Nwin =  atoi(word[1]) ;   // pass keyword
 
2498
      writearg(coarsecorrinput.Nwin);
 
2499
      if (coarsecorrinput.Nwin > 10000)
 
2500
        {
 
2501
        PRINT_ERROR("Too many windows requested (CC_NWIN > 10000).")
 
2502
        throw(keyword_error);
 
2503
        }
 
2504
      }
 
2505
 
 
2506
// **********************************************************************
 
2507
    else if (!strcmp(keyword,"CC_IN_POS"))            // file with #windows positions
 
2508
      {                                               
 
2509
      strcpy(coarsecorrinput.ifpositions,  word[1] );   // pass keyword
 
2510
      writearg(coarsecorrinput.ifpositions);
 
2511
      }
 
2512
 
 
2513
// **********************************************************************
 
2514
    else if (!strcmp(keyword,"CC_WINSIZE"))           // windowsize for coarse correlation
 
2515
      {                                               
 
2516
      coarsecorrinput.MasksizeL  =  atoi(word[1]) ;     // pass keyword
 
2517
      coarsecorrinput.MasksizeP  =  atoi(word[2]) ;     // pass keyword
 
2518
      writearg(coarsecorrinput.MasksizeL);
 
2519
      writearg(coarsecorrinput.MasksizeP);
 
2520
      if (coarsecorrinput.MasksizeL > 10240 || coarsecorrinput.MasksizeP > 4096)   // [TODO] move MAX constant values to constant.hh
 
2521
              {
 
2522
        PRINT_ERROR("Too large correlation window (CC_WINSIZE(l,p) > [10240,4096] ).");
 
2523
        throw(keyword_error);
 
2524
              }
 
2525
      }
 
2526
 
 
2527
// **********************************************************************
 
2528
    else if (!strcmp(keyword,"CC_ACC"))               // Searchdomain for correlation
 
2529
      {                                               //  coarse correlation
 
2530
      coarsecorrinput.AccL  =  atoi(word[1]) ;  // pass keyword
 
2531
      coarsecorrinput.AccP  =  atoi(word[2]) ;  // pass keyword
 
2532
      writearg(coarsecorrinput.AccL);
 
2533
      writearg(coarsecorrinput.AccP);
 
2534
      if (coarsecorrinput.AccL > 1000 || coarsecorrinput.AccP > 1000)
 
2535
              {
 
2536
        PRINT_ERROR("Too large searchwindow (CC_ACC > 1000).");
 
2537
        throw(keyword_error);
 
2538
              }
 
2539
      if (coarsecorrinput.AccL == 0 || coarsecorrinput.AccP == 0)
 
2540
              {
 
2541
        PRINT_ERROR("Acc = 0 ?(CC_ACC).");
 
2542
        throw(keyword_error);
 
2543
              }
 
2544
      }
 
2545
 
 
2546
// **********************************************************************
 
2547
    else if (!strcmp(keyword,"CC_INITOFF"))             // Initial offset
 
2548
      {
 
2549
      keyword  =  word[1] ;     // pass keyword
 
2550
      char *keyword2 =  word[2] ;       // pass keyword
 
2551
      writearg(keyword);
 
2552
      writearg(keyword2);
 
2553
      if (!strcmp(keyword,"ORBIT") ||                   // use value of precise orbits
 
2554
          !strcmp(keyword,"orbit"))
 
2555
        {
 
2556
        coarsecorrinput.initoffsetL = NaN;              // flag used in main, see processor.cc
 
2557
        coarsecorrinput.initoffsetP = NaN;              // flag used in main
 
2558
        INFO << "CC_INITOFF: \tInitial offsets from COARSEORB: " << generalinput.i_resfile;
 
2559
        INFO.print();
 
2560
        }
 
2561
      else if (isdigit(keyword2[0]) || keyword2[0]=='-') // likely to be 2 numbers
 
2562
                                                                           // BK19/1/00 thanks to m.goos for '-'
 
2563
        {
 
2564
        //coarsecorrinput.initoffsetL = atof(keyword);
 
2565
        //coarsecorrinput.initoffsetP = atof(keyword2);
 
2566
        coarsecorrinput.initoffsetL = atoi(keyword);
 
2567
        coarsecorrinput.initoffsetP = atoi(keyword2);
 
2568
        }
 
2569
      else
 
2570
        {
 
2571
        ERROR << "CC_INITOFF: unknown input: "
 
2572
             <<  keyword << ", " << keyword2
 
2573
             << " on line "
 
2574
             << linecnt << ".";
 
2575
              PRINT_ERROR(ERROR.get_str())
 
2576
        throw(keyword_error);
 
2577
        }
 
2578
      }
 
2579
 
 
2580
// **********************************************************************
 
2581
// *** FINE COREGISTRATION
 
2582
// **********************************************************************
 
2583
    else if (!strcmp(keyword,"FC_NWIN"))              // #windows for fine correlation
 
2584
      {                                               
 
2585
      fineinput.Nwin =  atoi(word[1]) ;         // pass keyword
 
2586
      writearg(fineinput.Nwin);
 
2587
      if (fineinput.Nwin > 100000)              // [MA] change this to a higher value for SPT
 
2588
              {
 
2589
        PRINT_ERROR("Too many windows requested (FC_NWIN).")
 
2590
        throw(keyword_error);
 
2591
              }
 
2592
      }
 
2593
 
 
2594
// **********************************************************************
 
2595
    else if (!strcmp(keyword,"FC_IN_POS"))            // file with #windows positions
 
2596
      {                                               
 
2597
      strcpy(fineinput.ifpositions,  word[1] );         // pass keyword
 
2598
      writearg(fineinput.ifpositions);
 
2599
      }
 
2600
 
 
2601
// **********************************************************************
 
2602
    else if (!strcmp(keyword,"FC_WINSIZE"))           // windowsize for fine correlation
 
2603
      {                                               
 
2604
      fineinput.MasksizeL  =  atoi(word[1]) ;   // pass keyword
 
2605
      fineinput.MasksizeP  =  atoi(word[2]) ;   // pass keyword
 
2606
      writearg(fineinput.MasksizeL);
 
2607
      writearg(fineinput.MasksizeP);
 
2608
      if (fineinput.MasksizeL > 1024 || fineinput.MasksizeP > 1024)
 
2609
        {
 
2610
        PRINT_ERROR("Too large correlation window (FC_WINSIZE).")
 
2611
        throw(keyword_error);
 
2612
        }
 
2613
      }
 
2614
 
 
2615
// **********************************************************************
 
2616
    else if (!strcmp(keyword,"FC_ACC"))               // Searchdomain for correlation
 
2617
      {                                               //  fine correlation
 
2618
      fineinput.AccL =  atoi(word[1]);  // pass keyword
 
2619
      fineinput.AccP =  atoi(word[2]);  // pass keyword
 
2620
      writearg(fineinput.AccL);
 
2621
      writearg(fineinput.AccP);
 
2622
      if (fineinput.AccL > 1000 || fineinput.AccP > 1000)
 
2623
        {
 
2624
        PRINT_ERROR("Too large searchwindow (FC_ACC).")
 
2625
        throw(keyword_error);
 
2626
        }
 
2627
      if (fineinput.AccL == 0 || fineinput.AccP == 0)
 
2628
        {
 
2629
        PRINT_ERROR("Acc = 0 ?(FC_ACC).")
 
2630
        throw(keyword_error);
 
2631
        }
 
2632
      }
 
2633
 
 
2634
// **********************************************************************
 
2635
    else if (!strcmp(keyword,"FC_INITOFF"))             // Initial offset
 
2636
      {
 
2637
      keyword        =  word[1] ;       // pass keyword
 
2638
      char *keyword2 =  word[2] ;       // pass keyword
 
2639
      writearg(keyword);
 
2640
      writearg(keyword2);
 
2641
      if (!strcmp(keyword,"COARSECORR") 
 
2642
       || !strcmp(keyword,"coarsecorr"))                // use value of coarse correlation
 
2643
        {
 
2644
        fineinput.initoffsetL = NaN;                    // flag used in main
 
2645
        fineinput.initoffsetP = NaN;                    // flag used in main
 
2646
        INFO << "FC_INITOFF: \tInitial offset from COARSECORR: "
 
2647
        << generalinput.i_resfile;
 
2648
        INFO.print();
 
2649
        }
 
2650
      else if (isdigit(keyword2[0]) || keyword2[0]=='-') // likely to be 2 numbers
 
2651
                                                // BK19/1/00 thanks to M.Goos for '-'
 
2652
        {
 
2653
        fineinput.initoffsetL = atoi(keyword);
 
2654
        fineinput.initoffsetP = atoi(keyword2);
 
2655
        }
 
2656
      else
 
2657
        {
 
2658
        ERROR << "FC_INITOFF: unknown input: "
 
2659
             <<  keyword << ", " << keyword2
 
2660
             << " on line "
 
2661
             << linecnt << ".";
 
2662
             PRINT_ERROR(ERROR.get_str())
 
2663
             throw(keyword_error);
 
2664
        }
 
2665
      }
 
2666
 
 
2667
// **********************************************************************
 
2668
    else if (!strcmp(keyword,"FC_METHOD"))            // method selector fine coreg
 
2669
      {                                               
 
2670
      keyword =  word[1] ;      // pass keyword
 
2671
      writearg(keyword);
 
2672
      toupper(keyword);
 
2673
      if (!strcmp(keyword,"CMPLXFFT")) 
 
2674
       {
 
2675
        //fineinput.method=fc_cmplxfft;                 // default
 
2676
        PRINT_ERROR("CMPLXFFT not implemented in v1.0 of Doris.")
 
2677
        throw(keyword_error);
 
2678
       }
 
2679
      else if (!strcmp(keyword,"CMPLXSPACE"))
 
2680
       {
 
2681
        //fineinput.method=fc_cmplxspace;
 
2682
       PRINT_ERROR("CMPLXSPACE not implemented in v1.0 of Doris.")
 
2683
       throw(keyword_error);
 
2684
       }
 
2685
      else if (!strcmp(keyword,"MAGFFT"))
 
2686
        fineinput.method=fc_magfft;
 
2687
      else if (!strcmp(keyword,"MAGSPACE"))
 
2688
        fineinput.method=fc_magspace;
 
2689
      else if (!strcmp(keyword,"OVERSAMPLE"))
 
2690
        fineinput.method=fc_oversample;
 
2691
      else
 
2692
        {
 
2693
        ERROR << "FC_METHOD: method " <<  keyword
 
2694
             << " not known for fine coregistration on line "
 
2695
             << linecnt << ".";
 
2696
        PRINT_ERROR(ERROR.get_str())
 
2697
        throw(keyword_error);
 
2698
        }
 
2699
      }
 
2700
 
 
2701
// **********************************************************************
 
2702
    else if (!strcmp(keyword,"FC_OSFACTOR"))          // oversampling factor
 
2703
      {                                               
 
2704
      fineinput.osfactor =  atoi(word[1]) ;     // pass keyword
 
2705
      writearg(fineinput.osfactor);
 
2706
      }
 
2707
 
 
2708
// **********************************************************************
 
2709
    else if (!strcmp(keyword,"FC_PLOT"))              // plotting results
 
2710
      {                                               
 
2711
      fineinput.plotoffsets = true;
 
2712
      fineinput.plotthreshold =  atof(word[1]) ;        // pass keyword
 
2713
      keyword =  word[2] ;      // pass keyword
 
2714
      writearg(fineinput.plotthreshold);
 
2715
      writearg(keyword);
 
2716
      toupper(keyword);
 
2717
      if (!strcmp(keyword,"BG"))
 
2718
        fineinput.plotmagbg = true;
 
2719
      else if (!strcmp(keyword,"NOBG"))
 
2720
        fineinput.plotmagbg = false;
 
2721
      else if (!strcmp(keyword,"ON"))           // actually not allowed...
 
2722
        fineinput.plotoffsets = true;
 
2723
      else if (!strcmp(keyword,"OFF"))          // actually not allowed...
 
2724
        fineinput.plotoffsets = false;
 
2725
      else
 
2726
        WARNING.print("FC_PLOT: missing argument(s). (default: 0.4 NOBG)");
 
2727
      }
 
2728
 
 
2729
// ____ start added by FvL ____
 
2730
 
 
2731
// **********************************************************************
 
2732
// *** RELATIVE TIMING ERROR
 
2733
// **********************************************************************
 
2734
 
 
2735
    else if (!strcmp(keyword,"RTE_THRESHOLD"))         // treshhold value
 
2736
      {                                               
 
2737
      reltiminginput.threshold =  atof(word[1]) ;       // pass keyword
 
2738
      writearg(reltiminginput.threshold);
 
2739
      if (reltiminginput.threshold > 1)
 
2740
        {
 
2741
        PRINT_ERROR("RTE_THRESHOLD: threshold > 1.")
 
2742
              throw(keyword_error);
 
2743
        }
 
2744
      }
 
2745
 
 
2746
// **********************************************************************
 
2747
    else if (!strcmp(keyword,"RTE_MAXITER"))     // max number of offsets to reject
 
2748
      {                                               
 
2749
      reltiminginput.maxiter =  atoi(word[1]) ;         // pass keyword
 
2750
      writearg(reltiminginput.maxiter);
 
2751
      if (reltiminginput.maxiter < 0)
 
2752
        {
 
2753
        WARNING.print("RTE_MAXITER: max. number of points to remove < 0? (using 0)");
 
2754
        reltiminginput.maxiter = 0;
 
2755
        }
 
2756
      }
 
2757
 
 
2758
// **********************************************************************
 
2759
    else if (!strcmp(keyword,"RTE_K_ALPHA"))     // critical value for outlier removal
 
2760
      {                                               
 
2761
      reltiminginput.k_alpha =  atof(word[1]) ;         // pass keyword
 
2762
      writearg(reltiminginput.k_alpha);
 
2763
      if (reltiminginput.k_alpha < 0)
 
2764
        {
 
2765
        WARNING.print("RTE_K_ALPHA: critical value < 0.0?");
 
2766
        reltiminginput.k_alpha = 1.97;
 
2767
        }
 
2768
      }
 
2769
 
 
2770
 
 
2771
// **********************************************************************
 
2772
// *** DEM ASSISTED COREGISTRATION
 
2773
// **********************************************************************
 
2774
 
 
2775
    else if (!strcmp(keyword,"DAC_IN_DEM"))          // input file
 
2776
      {
 
2777
      strcpy(demassistinput.firefdem,  word[1] );       // pass keyword
 
2778
      writearg(demassistinput.firefdem);
 
2779
      }
 
2780
 
 
2781
// **********************************************************************
 
2782
    else if (!strcmp(keyword,"DAC_IN_FORMAT"))       //  format input file
 
2783
      {
 
2784
      keyword =  word[1];       // pass keyword
 
2785
      writearg(keyword);
 
2786
      toupper(keyword);
 
2787
      if (!strcmp(keyword,"R4") || !strcmp(keyword,"REAL4"))
 
2788
        demassistinput.iformatflag = FORMATR4;
 
2789
      else if (!strcmp(keyword,"I2") || !strcmp(keyword,"SHORT"))
 
2790
        demassistinput.iformatflag = FORMATI2;  // default
 
2791
      else if (!strcmp(keyword,"I2_BIGENDIAN") || 
 
2792
               !strcmp(keyword,"SHORT_BIGENDIAN"))
 
2793
        demassistinput.iformatflag = FORMATI2_BIGENDIAN;        // default
 
2794
      else if (!strcmp(keyword,"R8") || !strcmp(keyword,"REAL8"))
 
2795
        demassistinput.iformatflag = FORMATR8;
 
2796
      else
 
2797
        {
 
2798
        ERROR << "DAC_IN_FORMAT: input format "
 
2799
             <<  keyword
 
2800
             << " not known (R4 R8 I2 (native) SHORT_BIGENDIAN); line "
 
2801
             << linecnt << ".";
 
2802
        PRINT_ERROR(ERROR.get_str())
 
2803
        throw(keyword_error);
 
2804
        }
 
2805
      }
 
2806
 
 
2807
// **********************************************************************
 
2808
    else if (!strcmp(keyword,"DAC_IN_SIZE"))         // nrow ncols (lat lon)
 
2809
      {
 
2810
      char *pLast1, *pLast2 = NULL;
 
2811
      demassistinput.demrows = strtoul(word[1], &pLast1, BASE10); 
 
2812
      demassistinput.demcols = strtoul(word[2], &pLast2, BASE10);
 
2813
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
2814
       {
 
2815
        ERROR << "DAC_IN_SIZE: "  << word[1] << " : " 
 
2816
              << word[2] << " are not valid.";
 
2817
        PRINT_ERROR(ERROR.get_str())
 
2818
        throw(keyword_error);
 
2819
       }
 
2820
      writearg(demassistinput.demrows);
 
2821
      writearg(demassistinput.demcols);
 
2822
      }
 
2823
 
 
2824
// **********************************************************************
 
2825
    else if (!strcmp(keyword,"DAC_IN_DELTA"))        // degrees delta lat lon
 
2826
      {
 
2827
      demassistinput.demdeltalat =  atof(word[1]) ;     // pass keyword
 
2828
      keyword                    =  word[2] ;         // update keyword
 
2829
      writearg(demassistinput.demdeltalat);
 
2830
      writearg(keyword);  // lon
 
2831
      if (isdigit(keyword[0]) || keyword[0]=='.')    // likely to be 2 numbers
 
2832
        demassistinput.demdeltalon = atof(keyword);
 
2833
      else // default same gridsize
 
2834
        demassistinput.demdeltalon = demassistinput.demdeltalat;
 
2835
 
 
2836
      // ______ Store as radians ______
 
2837
      demassistinput.demdeltalat = deg2rad(demassistinput.demdeltalat);
 
2838
      demassistinput.demdeltalon = deg2rad(demassistinput.demdeltalon);
 
2839
      }
 
2840
 
 
2841
// **********************************************************************
 
2842
    else if (!strcmp(keyword,"DAC_IN_UL"))           // upperleft coordinates
 
2843
      {
 
2844
      char *pLast1, *pLast2 = NULL;
 
2845
      demassistinput.demlatleftupper = strtod(word[1], &pLast1);
 
2846
                  demassistinput.demlonleftupper = strtod(word[2], &pLast2);
 
2847
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert
 
2848
       {
 
2849
        ERROR << "DAC_IN_UL: "  << word[1] << " : "
 
2850
                 << word[2] << " are not valid.";
 
2851
        PRINT_ERROR(ERROR.get_str())
 
2852
        throw(keyword_error);
 
2853
       }
 
2854
 
 
2855
      writearg(demassistinput.demlatleftupper);
 
2856
      writearg(demassistinput.demlonleftupper);
 
2857
      demassistinput.demlatleftupper = deg2rad(demassistinput.demlatleftupper);
 
2858
      demassistinput.demlonleftupper = deg2rad(demassistinput.demlonleftupper);
 
2859
      }
 
2860
 
 
2861
// **********************************************************************
 
2862
    else if (!strcmp(keyword,"DAC_IN_NODATA"))       // flag for no data
 
2863
      {
 
2864
      demassistinput.demnodata =  atof(word[1]) ;       // pass keyword
 
2865
      writearg(demassistinput.demnodata);
 
2866
      }
 
2867
 
 
2868
// **********************************************************************
 
2869
    else if (!strcmp(keyword,"DAC_OUT_DEM"))          // name of output file
 
2870
      {
 
2871
      strcpy(demassistinput.fodem,  word[1] );  // pass keyword
 
2872
      writearg(demassistinput.fodem);
 
2873
      }
 
2874
 
 
2875
// **********************************************************************
 
2876
    else if (!strcmp(keyword,"DAC_OUT_DEMI"))          // name of output file
 
2877
      {
 
2878
      strcpy(demassistinput.fodemi,  word[1] );         // pass keyword
 
2879
      writearg(demassistinput.fodemi);
 
2880
      }
 
2881
 
 
2882
// **********************************************************************
 
2883
    else if (!strcmp(keyword,"DAC_OUT_DEM_LP"))        // name of output file
 
2884
      {
 
2885
      strcpy(demassistinput.forefdemhei,  word[1] );    // pass keyword
 
2886
      writearg(demassistinput.forefdemhei);
 
2887
      }
 
2888
 
 
2889
// ____ end added by FvL ____
 
2890
 
 
2891
 
 
2892
// **********************************************************************
 
2893
// *** COMPUTATION OF COREGISTRATION PARAMETERS
 
2894
// **********************************************************************
 
2895
    else if (!strcmp(keyword,"CPM_THRESHOLD"))         // treshhold value
 
2896
      {                                               
 
2897
      coregpminput.threshold =  atof(word[1]) ;         // pass keyword
 
2898
      writearg(coregpminput.threshold);
 
2899
      if (coregpminput.threshold > 1)
 
2900
        {
 
2901
        PRINT_ERROR("CPM_THRESHOLD: threshold > 1.")
 
2902
        throw(keyword_error);
 
2903
        }
 
2904
      }
 
2905
 
 
2906
// **********************************************************************
 
2907
    else if (!strcmp(keyword,"CPM_DEGREE"))           // degree of polynomial
 
2908
      {                                               
 
2909
      coregpminput.degree =  atoi(word[1]) ;    // pass keyword
 
2910
      writearg(coregpminput.degree);
 
2911
      if (coregpminput.degree > 4)
 
2912
        WARNING.print("CPM_DEGREE: degree > 4 dangerous at edges?");
 
2913
      }
 
2914
 
 
2915
// **********************************************************************
 
2916
    else if (!strcmp(keyword,"CPM_WEIGHT"))           // weightmatrix
 
2917
      {                                               
 
2918
      keyword =  word[1] ;      // pass keyword
 
2919
      writearg(keyword);
 
2920
      toupper(keyword);
 
2921
      if (!strcmp(keyword,"NONE"))
 
2922
        coregpminput.weightflag = 0;          // default
 
2923
      else if (!strcmp(keyword,"LINEAR"))
 
2924
        coregpminput.weightflag = 1;
 
2925
      else if (!strcmp(keyword,"QUADRATIC"))
 
2926
        coregpminput.weightflag = 2;
 
2927
      else if (!strcmp(keyword,"BAMLER"))
 
2928
        coregpminput.weightflag = 3;
 
2929
      else
 
2930
        {
 
2931
        ERROR << "CPM_WEIGHT: data weighting option: "
 
2932
             <<  keyword
 
2933
             << " not known for computation of coregistration parameters on line "
 
2934
             << linecnt << ".";
 
2935
            PRINT_ERROR(ERROR.get_str())
 
2936
            throw(keyword_error);
 
2937
        }
 
2938
      }
 
2939
 
 
2940
// **********************************************************************
 
2941
    else if (!strcmp(keyword,"CPM_MAXITER"))     // max number of offsets to reject
 
2942
      {                                               
 
2943
      coregpminput.maxiter =  atoi(word[1]) ;   // pass keyword
 
2944
      writearg(coregpminput.maxiter);
 
2945
      if (coregpminput.maxiter < 0)
 
2946
        {
 
2947
        WARNING.print("CPM_MAXITER: max. number of points to remove < 0? (using 0)");
 
2948
        coregpminput.maxiter = 0;
 
2949
        }
 
2950
      }
 
2951
 
 
2952
// **********************************************************************
 
2953
    else if (!strcmp(keyword,"CPM_K_ALPHA"))     // critical value for outlier removal
 
2954
      {                                               
 
2955
      coregpminput.k_alpha =  atof(word[1]) ;   // pass keyword
 
2956
      writearg(coregpminput.k_alpha);
 
2957
      if (coregpminput.k_alpha < 0)
 
2958
        {
 
2959
        WARNING.print("CPM_K_ALPHA: critical value < 0.0?");
 
2960
        coregpminput.k_alpha = 1.97;
 
2961
        }
 
2962
      }
 
2963
 
 
2964
// **********************************************************************
 
2965
    else if (!strcmp(keyword,"CPM_DUMP"))               // boolean
 
2966
      {
 
2967
      keyword =  word[1] ;      // pass keyword
 
2968
      writearg(keyword);
 
2969
      toupper(keyword);
 
2970
      if (!strcmp(keyword,"OFF")) 
 
2971
        coregpminput.dumpmodel = false;
 
2972
      else if (!strcmp(keyword,"ON")    ||
 
2973
               !strncmp(keyword,"//",2) ||              // comment
 
2974
               !strncmp(keyword,"#",1)  ||              // comment
 
2975
               !(keyword[0] == '\0'))                   // no keyword
 
2976
        coregpminput.dumpmodel = true;
 
2977
      else
 
2978
        {
 
2979
        WARNING << "CPM_DUMP: line " << linecnt 
 
2980
             << ": argument: " << keyword 
 
2981
             << " not recognized, no dumping to files.";
 
2982
        WARNING.print();
 
2983
        }
 
2984
      }
 
2985
 
 
2986
// **********************************************************************
 
2987
    else if (!strcmp(keyword,"CPM_PLOT"))           // plotting results
 
2988
      {                                               
 
2989
      coregpminput.plot = true;
 
2990
      keyword =  word[1] ;      // pass keyword
 
2991
      writearg(keyword);
 
2992
      toupper(keyword);
 
2993
      if (!strcmp(keyword,"BG"))
 
2994
        coregpminput.plotmagbg = true;
 
2995
      else if (!strcmp(keyword,"NOBG"))
 
2996
        coregpminput.plotmagbg = false;
 
2997
      else if (!strcmp(keyword,"ON"))           // actually not allowed...
 
2998
        coregpminput.plot = true;
 
2999
      else if (!strcmp(keyword,"OFF"))          // actually not allowed...
 
3000
        coregpminput.plot = false;
 
3001
      else
 
3002
        WARNING.print("CPM_PLOT: missing argument. (default NOBG magnitude background)");
 
3003
      }
 
3004
 
 
3005
 
 
3006
// **********************************************************************
 
3007
// *** RANGE FILTERING
 
3008
// **********************************************************************
 
3009
    else if (!strcmp(keyword,"RF_METHOD"))            // method range filtering
 
3010
      {
 
3011
      keyword =  word[1] ;      // pass keyword
 
3012
      writearg(keyword);
 
3013
      toupper(keyword);
 
3014
      if (!strcmp(keyword,"ADAPTIVE"))
 
3015
        filtrangeinput.method = rf_adaptive;
 
3016
      else if (!strcmp(keyword,"PORBITS"))
 
3017
        filtrangeinput.method = rf_porbits;
 
3018
      else
 
3019
        {
 
3020
        ERROR << "RF_METHOD: method "
 
3021
             <<  keyword
 
3022
             << " not known for range filtering. line "
 
3023
             << linecnt << ".";
 
3024
        PRINT_ERROR(ERROR.get_str())
 
3025
        throw(keyword_error);
 
3026
        }
 
3027
      }
 
3028
 
 
3029
// **********************************************************************
 
3030
    else if (!strcmp(keyword,"RF_SLOPE"))               // terrain method porbits
 
3031
      {
 
3032
      filtrangeinput.terrainslope =  atof(word[1]) ;    // pass keyword
 
3033
      writearg(filtrangeinput.terrainslope);
 
3034
      deg2rad(filtrangeinput.terrainslope);
 
3035
      }
 
3036
 
 
3037
// **********************************************************************
 
3038
    else if (!strcmp(keyword,"RF_THRESHOLD"))           // threshhold value
 
3039
      {
 
3040
      filtrangeinput.SNRthreshold =  atof(word[1]) ;    // pass keyword
 
3041
      writearg(filtrangeinput.SNRthreshold);
 
3042
      }
 
3043
 
 
3044
// **********************************************************************
 
3045
    else if (!strcmp(keyword,"RF_HAMMING"))             // alpha
 
3046
      {
 
3047
      filtrangeinput.hammingalpha =  atof(word[1]) ;    // pass keyword
 
3048
      writearg(filtrangeinput.hammingalpha);
 
3049
      }
 
3050
 
 
3051
// **********************************************************************
 
3052
    else if (!strcmp(keyword,"RF_WEIGHTCORR"))          // boolean
 
3053
      {
 
3054
      keyword =  word[1] ;      // pass keyword
 
3055
      writearg(keyword);
 
3056
      toupper(keyword);
 
3057
      if (!strcmp(keyword,"OFF")) 
 
3058
        filtrangeinput.doweightcorrel = false;
 
3059
      else if (!strcmp(keyword,"ON")    ||
 
3060
               !strncmp(keyword,"//",2) ||              // comment
 
3061
               !strncmp(keyword,"#",1)  ||              // comment
 
3062
               !(keyword[0] == '\0'))                   // no keyword
 
3063
        filtrangeinput.doweightcorrel = true;
 
3064
      else
 
3065
        {
 
3066
        filtrangeinput.doweightcorrel = false;          // default already...
 
3067
        WARNING << "RF_WEIGHTCORREL: line " << linecnt 
 
3068
             << ": argument: " << keyword 
 
3069
             << " not recognized, weighting correlation set to OFF.";
 
3070
        WARNING.print();
 
3071
        }
 
3072
      }
 
3073
 
 
3074
// **********************************************************************
 
3075
    else if (!strcmp(keyword,"RF_OVERSAMPLE"))         // int
 
3076
      {
 
3077
      filtrangeinput.oversample =  atoi(word[1]) ;      // pass keyword
 
3078
      writearg(filtrangeinput.oversample);
 
3079
      }
 
3080
 
 
3081
// **********************************************************************
 
3082
    else if (!strcmp(keyword,"RF_NLMEAN"))              // take mean over nlmean lines
 
3083
      {
 
3084
      filtrangeinput.nlmean =  atoi(word[1]) ;         // pass keyword
 
3085
      if (!isodd(filtrangeinput.nlmean))               // check if ODD value  [MA]                   
 
3086
        {
 
3087
        PRINT_ERROR("RF_NLMEAN value has to be odd.")
 
3088
        throw(argument_error);
 
3089
        }
 
3090
      writearg(filtrangeinput.nlmean);
 
3091
      }
 
3092
 
 
3093
// **********************************************************************
 
3094
    else if (!strcmp(keyword,"RF_FFTLENGTH"))           // adaptive length
 
3095
      {
 
3096
      filtrangeinput.fftlength =  atoi(word[1]) ;       // pass keyword
 
3097
      writearg(filtrangeinput.fftlength);
 
3098
      }
 
3099
 
 
3100
// **********************************************************************
 
3101
    else if (!strcmp(keyword,"RF_OVERLAP"))             // overlap blocks
 
3102
      {
 
3103
      filtrangeinput.overlap =  atoi(word[1]) ;         // pass keyword
 
3104
      writearg(filtrangeinput.overlap);
 
3105
      }
 
3106
 
 
3107
// **********************************************************************
 
3108
    else if (!strcmp(keyword,"RF_OUT_MASTER"))          // filename
 
3109
      {
 
3110
      strcpy(filtrangeinput.fomaster,  word[1] );       // pass keyword
 
3111
      writearg(filtrangeinput.fomaster);
 
3112
      }
 
3113
 
 
3114
// **********************************************************************
 
3115
    else if (!strcmp(keyword,"RF_OUT_SLAVE"))           // filename
 
3116
      {
 
3117
      strcpy(filtrangeinput.foslave,  word[1] );        // pass keyword
 
3118
      writearg(filtrangeinput.foslave);
 
3119
      }
 
3120
 
 
3121
// **********************************************************************
 
3122
    else if (!strcmp(keyword,"RF_OUT_FORMAT"))          // output format
 
3123
      {
 
3124
      keyword =  word[1] ;      // pass keyword
 
3125
      writearg(keyword);
 
3126
      toupper(keyword);
 
3127
      if (!strcmp(keyword,"CR4"))
 
3128
        filtrangeinput.oformatflag = FORMATCR4;         // default
 
3129
      else if (!strcmp(keyword,"CI2"))
 
3130
        filtrangeinput.oformatflag = FORMATCI2;
 
3131
      else
 
3132
        {
 
3133
        ERROR << "RF_OUT_FORMAT: output format "
 
3134
             <<  keyword
 
3135
             << " not known for range filtering. line "
 
3136
             << linecnt << ".";
 
3137
        PRINT_ERROR(ERROR.get_str())
 
3138
        throw(keyword_error);
 
3139
        }
 
3140
      }
 
3141
 
 
3142
 
 
3143
// **********************************************************************
 
3144
// *** FLAT EARTH CORRECTION == compute reference phase since Feb-2000
 
3145
// **********************************************************************
 
3146
    else if (!strcmp(keyword,"FE_METHOD"))            // method selector flatearth
 
3147
      {                                               
 
3148
      keyword =  word[1] ;      // pass keyword
 
3149
      writearg(keyword);
 
3150
      toupper(keyword);
 
3151
      if (!strcmp(keyword,"PORBITS"))
 
3152
        comprefphainput.method=fe_porbits;
 
3153
      else if (!strcmp(keyword,"METHOD2"))
 
3154
        comprefphainput.method=fe_method2;
 
3155
      else
 
3156
        {
 
3157
        ERROR << "FE_METHOD: argument: " << keyword << " not recognized.";
 
3158
        PRINT_ERROR(ERROR.get_str())
 
3159
        throw(keyword_error);
 
3160
        }
 
3161
      }
 
3162
 
 
3163
// **********************************************************************
 
3164
    else if (!strcmp(keyword,"FE_DEGREE"))            // degree for flat earth correction
 
3165
      {                                               
 
3166
      comprefphainput.degree =  atoi(word[1]) ;         // pass keyword
 
3167
      writearg(comprefphainput.degree);
 
3168
      }
 
3169
 
 
3170
// **********************************************************************
 
3171
    else if (!strcmp(keyword,"FE_NPOINTS"))           // number of points used 
 
3172
      {                                               //  for estimation of polynomial
 
3173
      comprefphainput.Npoints =  atoi(word[1]) ;        // pass keyword          //  flat earth correction.
 
3174
      writearg(comprefphainput.Npoints);
 
3175
      }
 
3176
 
 
3177
// **********************************************************************
 
3178
    else if (!strcmp(keyword,"FE_IN_POS"))            // file with #windows positions
 
3179
      {                                               
 
3180
      strcpy(comprefphainput.ifpositions,  word[1] );   // pass keyword
 
3181
      writearg(comprefphainput.ifpositions);
 
3182
      }
 
3183
 
 
3184
 
 
3185
// **********************************************************************
 
3186
// *** RESAMPLING (SLAVE)
 
3187
// **********************************************************************
 
3188
    else if (!strcmp(keyword,"RS_METHOD"))            // method selector resampling
 
3189
      {
 
3190
      keyword =  word[1] ;      // pass keyword
 
3191
      writearg(keyword);
 
3192
      toupper(keyword);
 
3193
      if (!strcmp(keyword,"CC4P"))
 
3194
        resampleinput.method = rs_cc4p;                       // default
 
3195
      else if (!strcmp(keyword,"CC6P"))
 
3196
        resampleinput.method = rs_cc6p;
 
3197
      else if (!strcmp(keyword,"TS6P"))
 
3198
        resampleinput.method = rs_ts6p;
 
3199
      else if (!strcmp(keyword,"TS8P"))
 
3200
        resampleinput.method = rs_ts8p;
 
3201
      else if (!strcmp(keyword,"TS16P"))
 
3202
        resampleinput.method = rs_ts16p;
 
3203
      else if (!strcmp(keyword,"KNAB4P"))
 
3204
        resampleinput.method = rs_knab4p;
 
3205
      else if (!strcmp(keyword,"KNAB6P"))
 
3206
        resampleinput.method = rs_knab6p;
 
3207
      else if (!strcmp(keyword,"KNAB8P"))
 
3208
        resampleinput.method = rs_knab8p;
 
3209
      else if (!strcmp(keyword,"KNAB10P"))
 
3210
        resampleinput.method = rs_knab10p;
 
3211
      else if (!strcmp(keyword,"KNAB16P"))
 
3212
        resampleinput.method = rs_knab16p;
 
3213
      else if (!strcmp(keyword,"RC6P"))
 
3214
        resampleinput.method = rs_rc6p;
 
3215
      else if (!strcmp(keyword,"RC12P"))
 
3216
        resampleinput.method = rs_rc12p;
 
3217
      else if (!strcmp(keyword,"RECT"))
 
3218
        resampleinput.method = rs_rect;
 
3219
      else if (!strcmp(keyword,"TRI"))
 
3220
        resampleinput.method = rs_tri;
 
3221
      else
 
3222
        {
 
3223
        ERROR << "RS_METHOD: method "
 
3224
             <<  keyword
 
3225
             << " not known for resampling. line "
 
3226
             << linecnt << ".";
 
3227
        PRINT_ERROR(ERROR.get_str())
 
3228
        throw(keyword_error);
 
3229
        }
 
3230
      }
 
3231
 
 
3232
// **********************************************************************
 
3233
    else if (!strcmp(keyword,"RS_DBOW"))              // database output window
 
3234
      {
 
3235
      resampleinput.dbow.linelo  = atoi(word[1]);
 
3236
      resampleinput.dbow.linehi  = atoi(word[2]);
 
3237
      resampleinput.dbow.pixlo   = atoi(word[3]);
 
3238
      resampleinput.dbow.pixhi   = atoi(word[4]);
 
3239
      writearg(resampleinput.dbow.linelo);
 
3240
      writearg(resampleinput.dbow.linehi);
 
3241
      writearg(resampleinput.dbow.pixlo);
 
3242
      writearg(resampleinput.dbow.pixhi);
 
3243
      if (resampleinput.dbow.linelo <= 0 || 
 
3244
          resampleinput.dbow.pixlo <= 0 ||
 
3245
          resampleinput.dbow.linelo  > resampleinput.dbow.linehi ||
 
3246
          resampleinput.dbow.pixlo > resampleinput.dbow.pixhi)
 
3247
        {
 
3248
        ERROR << "code 300: Arguments of RS_DBOW card on line " << linecnt
 
3249
              << " missing. [RS_DBOW  min_line  max_line  min_pixel  max_pixel].";
 
3250
              PRINT_ERROR(ERROR.get_str())
 
3251
              throw(keyword_error);
 
3252
        }
 
3253
      }
 
3254
 
 
3255
// **********************************************************************
 
3256
    else if (!strcmp(keyword,"RS_DBOW_GEO"))  // database output
 
3257
                                              // window on GEO.LOCATION
 
3258
      {
 
3259
       // use dbow to store temp, compute later
 
3260
       real8 tmp_lat_0;
 
3261
       real8 tmp_lon_0; 
 
3262
       real8 tmp_height; // total height, not half.window
 
3263
       real8 tmp_width;  // total width, not half.windo
 
3264
        
 
3265
       char *pLast1, *pLast2, *pLast3, *pLast4 = NULL;
 
3266
       tmp_lat_0  = strtod(word[1], &pLast1); 
 
3267
       tmp_lon_0  = strtod(word[2], &pLast2);
 
3268
       tmp_height = strtod(word[3], &pLast2);
 
3269
       tmp_width  = strtod(word[4], &pLast2);
 
3270
      if ( pLast1 == word[1] || pLast2 == word[2] ||
 
3271
           pLast3 == word[3] || pLast4 == word[4]    ) // fails to convert one of them to double.
 
3272
       {
 
3273
        ERROR << "RS_DBOW_GEO: "  << word[1] << " : " 
 
3274
              << word[2] << " : " << word[3] << " : " << word[4] << " are not valid.";
 
3275
        PRINT_ERROR(ERROR.get_str())
 
3276
        throw(keyword_error);
 
3277
       }
 
3278
        writearg(tmp_lat_0);
 
3279
        writearg(tmp_lon_0);
 
3280
        writearg(tmp_height);
 
3281
        writearg(tmp_width);
 
3282
        
 
3283
        resampleinput.dbow_geo.linelo = uint((360.0+tmp_lat_0)*1e6);
 
3284
        resampleinput.dbow_geo.linehi = uint((360.0+tmp_lon_0)*1e6);
 
3285
        resampleinput.dbow_geo.pixlo  = uint(tmp_height);
 
3286
        resampleinput.dbow_geo.pixhi  = uint(tmp_width);
 
3287
 
 
3288
      }
 
3289
 
 
3290
// **********************************************************************
 
3291
    else if (!strcmp(keyword,"RS_OUT_FILE"))           // name of output file
 
3292
      {
 
3293
      switch (priorrs_fileout)
 
3294
        {
 
3295
        case true:
 
3296
          WARNING << "RS_OUT_FILE: line: " << linecnt << ": "
 
3297
              << "ignored due to prior occurence.";
 
3298
          WARNING.print();
 
3299
          break;
 
3300
        default:
 
3301
          priorrs_fileout = true;
 
3302
          strcpy(resampleinput.fileout,  word[1] );     // pass keyword (filename)
 
3303
          writearg(resampleinput.fileout);
 
3304
        }
 
3305
      }
 
3306
 
 
3307
// **********************************************************************
 
3308
    else if (!strcmp(keyword,"RS_OUT_FORMAT"))          // output format
 
3309
      {
 
3310
      keyword =  word[1] ;      // pass keyword
 
3311
      writearg(keyword);
 
3312
      toupper(keyword);
 
3313
      if (!strcmp(keyword,"CR4"))
 
3314
        resampleinput.oformatflag = FORMATCR4;          // default
 
3315
      else if (!strcmp(keyword,"CI2"))
 
3316
        resampleinput.oformatflag = FORMATCI2;
 
3317
      else
 
3318
        {
 
3319
        ERROR << "RS_OUT_FORMAT: output format "
 
3320
             <<  keyword
 
3321
             << " not known for resampling. line "
 
3322
             << linecnt << ".";
 
3323
        PRINT_ERROR(ERROR.get_str())
 
3324
        throw(keyword_error);
 
3325
        }
 
3326
      }
 
3327
 
 
3328
// **********************************************************************
 
3329
    else if (!strcmp(keyword,"RS_SHIFTAZI"))            // true: shift before rs.
 
3330
      {
 
3331
      keyword =  word[1] ;      // pass keyword
 
3332
      writearg(keyword);
 
3333
      toupper(keyword);
 
3334
      if (!strcmp(keyword,"ON"))
 
3335
        resampleinput.shiftazi = true;
 
3336
      else if (!strcmp(keyword,"OFF")   ||
 
3337
               !strncmp(keyword,"//",2) ||              // comment
 
3338
               !strncmp(keyword,"#",1)  ||              // comment
 
3339
               !(keyword[0] == '\0'))                   // no keyword
 
3340
        resampleinput.shiftazi = false;
 
3341
      else
 
3342
        {
 
3343
        resampleinput.shiftazi = true;
 
3344
        WARNING << "RS_SHIFTAZI: line: " << linecnt << ": unknown argument: "
 
3345
             << keyword << "; Set to ON (do shift azimuth spectrum).";
 
3346
        WARNING.print();
 
3347
        }
 
3348
      }
 
3349
 
 
3350
 
 
3351
// **********************************************************************
 
3352
// *** COMPUTATION OF INTERFEROGRAM
 
3353
// **********************************************************************
 
3354
    else if (!strcmp(keyword,"INT_METHOD"))            // method selector interfero
 
3355
      {
 
3356
      keyword =  word[1] ;      // pass keyword
 
3357
      writearg(keyword);
 
3358
      toupper(keyword);
 
3359
      if (!strcmp(keyword,"OLD"))
 
3360
        interferoinput.method = int_oldmethod;
 
3361
      else if (!strcmp(keyword,"OVERSAMPLE"))
 
3362
        interferoinput.method = int_oversample;
 
3363
      else
 
3364
        {
 
3365
        ERROR << "INT_METHOD: method "
 
3366
             <<  keyword
 
3367
             << " not known for interfero. line "
 
3368
             << linecnt << ".";
 
3369
        PRINT_ERROR(ERROR.get_str())
 
3370
        throw(keyword_error);
 
3371
        }
 
3372
      }
 
3373
 
 
3374
// **********************************************************************
 
3375
    else if (!strcmp(keyword,"INT_OUT_INT"))           // name of output file
 
3376
      {
 
3377
      strcpy(interferoinput.foint,  word[1] );  // pass keyword
 
3378
      writearg(interferoinput.foint);
 
3379
      }
 
3380
 
 
3381
// **********************************************************************
 
3382
    else if (!strcmp(keyword,"INT_OUT_CINT"))          // name of output file
 
3383
      {
 
3384
      strcpy(interferoinput.focint,  word[1] );         // pass keyword
 
3385
      writearg(interferoinput.focint);
 
3386
      }
 
3387
 
 
3388
// **********************************************************************
 
3389
//    else if (!strcmp(keyword,"INT_OUT_FE"))         // name of output file
 
3390
//      interferoinput.foflatearth =  word[1] ;         // pass keyword
 
3391
 
 
3392
// **********************************************************************
 
3393
    else if (!strcmp(keyword,"INT_MULTILOOK"))        // multilookfactors
 
3394
      {
 
3395
      interferoinput.multilookL  = atoi(word[1]);       // pass keyword
 
3396
      interferoinput.multilookP  = atoi(word[2]);       // pass keyword
 
3397
      writearg(interferoinput.multilookL);
 
3398
      writearg(interferoinput.multilookP);
 
3399
      }
 
3400
 
 
3401
// **********************************************************************
 
3402
// *** COMPUTATION OF COHERENCE
 
3403
// **********************************************************************
 
3404
    else if (!strcmp(keyword,"COH_METHOD"))            // method selector coherence
 
3405
      {
 
3406
      keyword =  word[1] ;      // pass keyword
 
3407
      writearg(keyword);
 
3408
      toupper(keyword);
 
3409
      if (!strcmp(keyword,"REFPHASE_ONLY"))                    // OLD
 
3410
        coherenceinput.method = coh_oldmethod;
 
3411
      else if (!strcmp(keyword,"INCLUDE_REFDEM"))              // NEW
 
3412
        coherenceinput.method = coh_newmethod;
 
3413
      else
 
3414
        {
 
3415
        ERROR << "COH_METHOD: method "
 
3416
             <<  keyword
 
3417
             << " not known for coherence. line "
 
3418
             << linecnt << ".";
 
3419
        PRINT_ERROR(ERROR.get_str())
 
3420
        throw(keyword_error);
 
3421
        }
 
3422
      }
 
3423
 
 
3424
// **********************************************************************
 
3425
    else if (!strcmp(keyword,"COH_OUT_COH"))          // name of output file
 
3426
      {
 
3427
      strcpy(coherenceinput.focoh,  word[1] );  // pass keyword
 
3428
      writearg(coherenceinput.focoh);
 
3429
      }
 
3430
 
 
3431
// **********************************************************************
 
3432
    else if (!strcmp(keyword,"COH_OUT_CCOH"))          // name of output file
 
3433
      {
 
3434
      strcpy(coherenceinput.foccoh,  word[1] );         // pass keyword
 
3435
      writearg(coherenceinput.foccoh);
 
3436
      }
 
3437
 
 
3438
// **********************************************************************
 
3439
    else if (!strcmp(keyword,"COH_MULTILOOK"))        // multilookfactors
 
3440
      {
 
3441
      coherenceinput.multilookL =  atoi(word[1]);       // pass keyword
 
3442
      coherenceinput.multilookP =  atoi(word[2]);       // pass keyword
 
3443
      writearg(coherenceinput.multilookL);
 
3444
      writearg(coherenceinput.multilookP);
 
3445
      }
 
3446
 
 
3447
// **********************************************************************
 
3448
    else if (!strcmp(keyword,"COH_WINSIZE"))          // estimator winsize
 
3449
      {
 
3450
      coherenceinput.cohsizeL =  atoi(word[1]);         // pass keyword
 
3451
      coherenceinput.cohsizeP =  atoi(word[2]);         // pass keyword
 
3452
      writearg(coherenceinput.cohsizeL);
 
3453
      writearg(coherenceinput.cohsizeP);
 
3454
      }
 
3455
 
 
3456
// **********************************************************************
 
3457
// *** SUBTRACTION OF REFERENCE PHASE
 
3458
// **********************************************************************
 
3459
    else if (!strcmp(keyword,"SRP_METHOD"))           // method selector ref. phase
 
3460
      {
 
3461
      keyword =  word[1] ;      // pass keyword
 
3462
      writearg(keyword);
 
3463
      toupper(keyword);
 
3464
      if (!strcmp(keyword,"POLYNOMIAL"))
 
3465
        subtrrefphainput.method = srp_polynomial;
 
3466
      else if (!strcmp(keyword,"EXACT"))
 
3467
        subtrrefphainput.method = srp_exact;
 
3468
      else
 
3469
        {
 
3470
        ERROR << "SRP_METHOD: method "
 
3471
             <<  keyword
 
3472
             << " not known for subtraction of ref. phase. line "
 
3473
             << linecnt << ".";
 
3474
        PRINT_ERROR(ERROR.get_str())
 
3475
        throw(keyword_error);
 
3476
        }
 
3477
      }
 
3478
 
 
3479
// **********************************************************************
 
3480
    else if (!strcmp(keyword,"SRP_OUT_CINT"))          // name of output file
 
3481
      {
 
3482
      strcpy(subtrrefphainput.focint,  word[1] );       // pass keyword
 
3483
      writearg(subtrrefphainput.focint);
 
3484
      }
 
3485
 
 
3486
// **********************************************************************
 
3487
    else if (!strcmp(keyword,"SRP_OUT_REFPHA"))       // name of output file
 
3488
      {
 
3489
      strcpy(subtrrefphainput.forefpha,  word[1] );     // pass keyword
 
3490
      writearg(subtrrefphainput.forefpha);
 
3491
      }
 
3492
 
 
3493
// **********************************************************************
 
3494
    else if (!strcmp(keyword,"SRP_DUMPREFPHA"))      // true: dump ref.pha
 
3495
      {
 
3496
      keyword =  word[1] ;      // pass keyword
 
3497
      writearg(keyword);
 
3498
      toupper(keyword);
 
3499
      if (!strcmp(keyword,"ON"))
 
3500
        subtrrefphainput.dumponlyrefpha = true;
 
3501
      else if (!strcmp(keyword,"OFF")   ||
 
3502
               !strncmp(keyword,"//",2) ||              // comment
 
3503
               !strncmp(keyword,"#",1)  ||              // comment
 
3504
               !(keyword[0] == '\0'))                   // no keyword
 
3505
        subtrrefphainput.dumponlyrefpha = false;
 
3506
      else
 
3507
        {
 
3508
        subtrrefphainput.dumponlyrefpha = false;
 
3509
        WARNING << "SRP_DUMPREFPHA: line: " << linecnt << ": unknown argument: "
 
3510
             << keyword << "; Set to OFF (no dump).";
 
3511
        WARNING.print();
 
3512
        }
 
3513
      }
 
3514
 
 
3515
// **********************************************************************
 
3516
 
 
3517
// ___________ added by FvL      
 
3518
    else if (!strcmp(keyword,"SRP_OUT_H2PH"))          // name of output file
 
3519
      {
 
3520
      strcpy(subtrrefphainput.foh2ph,  word[1] );       // pass keyword
 
3521
      writearg(subtrrefphainput.foh2ph);
 
3522
      }
 
3523
// ___________ end added by FvL
 
3524
 
 
3525
 
 
3526
// **********************************************************************
 
3527
    else if (!strcmp(keyword,"SRP_MULTILOOK"))        // multilookfactors
 
3528
      {
 
3529
      subtrrefphainput.multilookL  =  atoi(word[1]) ;   // pass keyword
 
3530
      keyword                      =  word[2] ;               // pass keyword
 
3531
      writearg(subtrrefphainput.multilookL);
 
3532
      writearg(keyword);
 
3533
      if (isdigit(keyword[0]))
 
3534
        subtrrefphainput.multilookP = atoi(keyword);
 
3535
      else                                              // default same factor
 
3536
        subtrrefphainput.multilookP = subtrrefphainput.multilookL;
 
3537
      }
 
3538
 
 
3539
// **********************************************************************
 
3540
// *** PHASE FILTER
 
3541
// **********************************************************************
 
3542
    else if (!strcmp(keyword,"PF_METHOD"))           // method selector phase filtering
 
3543
      {
 
3544
      keyword =  word[1] ;      // pass keyword
 
3545
      writearg(keyword);
 
3546
      toupper(keyword);
 
3547
      if (!strcmp(keyword,"GOLDSTEIN"))
 
3548
        filtphaseinput.method = fp_goldstein;
 
3549
      else if (!strcmp(keyword,"MODGOLDSTEIN"))
 
3550
        filtphaseinput.method = fp_modgoldstein;
 
3551
      else if (!strcmp(keyword,"SPATIALCONV"))
 
3552
        filtphaseinput.method = fp_spatialconv;
 
3553
      else if (!strcmp(keyword,"SPECTRAL"))
 
3554
        filtphaseinput.method = fp_spectral;
 
3555
      else
 
3556
        {
 
3557
        ERROR << "PF_METHOD: method "
 
3558
             <<  keyword
 
3559
             << " not known for phase filtering. line "
 
3560
             << linecnt << ".";
 
3561
             PRINT_ERROR(ERROR.get_str())
 
3562
             throw(keyword_error);
 
3563
        }
 
3564
      }
 
3565
 
 
3566
// **********************************************************************
 
3567
    else if (!strcmp(keyword,"PF_OUT_FILE"))          // filename
 
3568
      {
 
3569
      strcpy(filtphaseinput.fofiltphase,  word[1] );    // pass keyword
 
3570
      writearg(filtphaseinput.fofiltphase);
 
3571
      }
 
3572
 
 
3573
// **********************************************************************
 
3574
    else if (!strcmp(keyword,"PF_IN_FILE"))           // filename
 
3575
      {
 
3576
      strcpy(filtphaseinput.fifiltphase ,  word[1] );   // pass keyword
 
3577
      char *pLast = NULL;
 
3578
      filtphaseinput.finumlines = strtoul(word[1], &pLast, BASE10); // pass numoflines
 
3579
      if ( pLast == word[2] ) // fails to convert one of them to double.
 
3580
       {
 
3581
        ERROR << "PF_IN_FILE (numoflines): "  <<  word[2] << " are not valid.";
 
3582
        PRINT_ERROR(ERROR.get_str())
 
3583
        throw(keyword_error);
 
3584
       }
 
3585
      writearg(filtphaseinput.fifiltphase);
 
3586
      writearg(filtphaseinput.finumlines);
 
3587
      }
 
3588
 
 
3589
// **********************************************************************
 
3590
    else if (!strcmp(keyword,"PF_BLOCKSIZE"))         // buffersize
 
3591
      {
 
3592
      filtphaseinput.blocksize =  atoi(word[1]) ;       // pass keyword
 
3593
      writearg(filtphaseinput.blocksize);
 
3594
      }
 
3595
 
 
3596
// **********************************************************************
 
3597
    else if (!strcmp(keyword,"PF_ALPHA"))             // alpha
 
3598
      {
 
3599
      filtphaseinput.alpha =  atof(word[1]) ;   // pass keyword
 
3600
      writearg(filtphaseinput.alpha);
 
3601
      }
 
3602
 
 
3603
// **********************************************************************
 
3604
    else if (!strcmp(keyword,"PF_OVERLAP"))           // overlap
 
3605
      {
 
3606
      filtphaseinput.overlap =  atoi(word[1]) ;         // pass keyword
 
3607
      writearg(filtphaseinput.overlap);
 
3608
      }
 
3609
 
 
3610
// **********************************************************************
 
3611
    else if (!strcmp(keyword,"PF_KERNEL"))            // conv. kernel e.g. 3 1 1 1
 
3612
      {
 
3613
      keyword =  word[1] ;      // pass keyword
 
3614
      const int32 sizekernel = atoi(keyword);
 
3615
      writearg(sizekernel);
 
3616
      if (!(isodd(sizekernel)))
 
3617
        {
 
3618
         PRINT_ERROR("PF_KERNEL: size must be odd! (add 0, center around midpix)")
 
3619
         throw(keyword_error);
 
3620
        }
 
3621
      filtphaseinput.kernel.resize(1,sizekernel);
 
3622
      real4 sum=0.;
 
3623
      for (int32 argnum=0; argnum<sizekernel; ++argnum)
 
3624
        {
 
3625
         keyword =  word[1] ;   // pass keyword
 
3626
         if (!(isdigit(keyword[0])))
 
3627
         WARNING.print("kernel seems to be wrong?");
 
3628
         const real4 in = atof(keyword);
 
3629
         writearg(in);
 
3630
         filtphaseinput.kernel(0,argnum) = in;
 
3631
         sum += abs(in);                                        // kernel -1 1
 
3632
        }
 
3633
        if (sum!=1)
 
3634
        filtphaseinput.kernel /= sum;                   // normalize
 
3635
        INFO << "PF_KERNEL: Input kernel normalized by: " <<  sum;
 
3636
        INFO.print();
 
3637
      }
 
3638
 
 
3639
// **********************************************************************
 
3640
    else if (!strcmp(keyword,"PF_IN_KERNEL2D"))       // filename for ascii 2d kernel
 
3641
      {
 
3642
      strcpy(filtphaseinput.fikernel2d,  word[1] );     // pass keyword
 
3643
      writearg(filtphaseinput.fikernel2d);
 
3644
      }
 
3645
 
 
3646
// *******************************************************************
 
3647
// *** DINSAR
 
3648
// *******************************************************************
 
3649
    else if (!strcmp(keyword,"DI_OUT_FILE"))            // output filename
 
3650
      {                                               
 
3651
      strcpy(dinsarinput.fodinsar,  word[1] );  // pass keyword
 
3652
      writearg(dinsarinput.fodinsar);
 
3653
      }
 
3654
 
 
3655
    else if (!strcmp(keyword,"DI_OUT_SCALED"))          // output filename
 
3656
      {                                               
 
3657
      strcpy(dinsarinput.foscaleduint,  word[1] );      // pass keyword
 
3658
      writearg(dinsarinput.foscaleduint);
 
3659
      }
 
3660
 
 
3661
    else if (!strcmp(keyword,"DI_IN_TOPOMASTER"))       // input resultfilename
 
3662
      {                                               
 
3663
      strcpy(dinsarinput.topomasterresfile,  word[1] );         // pass keyword
 
3664
      writearg(dinsarinput.fodinsar);
 
3665
      }
 
3666
 
 
3667
    else if (!strcmp(keyword,"DI_IN_TOPOSLAVE"))        // input resultfilename
 
3668
      {                                               
 
3669
      strcpy(dinsarinput.toposlaveresfile,  word[1] );  // pass keyword
 
3670
      writearg(dinsarinput.fodinsar);
 
3671
      }
 
3672
 
 
3673
    else if (!strcmp(keyword,"DI_IN_TOPOINT"))          // input resultfilename
 
3674
      {                                               
 
3675
      strcpy(dinsarinput.topointresfile,  word[1] );    // pass keyword
 
3676
      writearg(dinsarinput.fodinsar);
 
3677
      }
 
3678
 
 
3679
 
 
3680
// **********************************************************************
 
3681
// *** COMPUTATION OF REFERENCE DEM (phase)
 
3682
// **********************************************************************
 
3683
//    else if (!strcmp(keyword,"CRD_METHOD"))          // name of output file
 
3684
//      {
 
3685
//      filename =  word[1] ;   // pass keyword
 
3686
//      writearg(keyword2);
 
3687
//      toupper(keyword2);
 
3688
//      if (!strcmp(keyword2,"TRILINEAR") || !strcmp(keyword2,"TRI_LINEAR") ||
 
3689
//          !strcmp(keyword2,"TRILIN") || !strcmp(keyword2,"TRI_LIN"))
 
3690
//        comprefdeminput.method = crd_trilinear;
 
3691
//      else if (!strcmp(keyword2,"NN") || !strcmp(keyword2,"NEAREST") ||
 
3692
//               !strcmp(keyword2,"NEAREST_NEIGHBOR" ))
 
3693
//        comprefdeminput.method = crd_nearest;
 
3694
//      else
 
3695
//        {
 
3696
//        ERROR << "CRD_METHOD: "
 
3697
//             <<  filename
 
3698
//             << " not known (use TRILINEAR or NEAREST); line "
 
3699
//             << linecnt << ".";
 
3700
//      PRINT_ERROR(ERROR.get_str())
 
3701
//      throw(keyword_error);
 
3702
//        }
 
3703
//      }
 
3704
 
 
3705
// **********************************************************************
 
3706
    else if (!strcmp(keyword,"CRD_IN_DEM"))          // input file
 
3707
      {
 
3708
      strcpy(comprefdeminput.firefdem,  word[1] );      // pass keyword
 
3709
      writearg(comprefdeminput.firefdem);
 
3710
      }
 
3711
 
 
3712
// **********************************************************************
 
3713
    else if (!strcmp(keyword,"CRD_IN_FORMAT"))       //  format input file
 
3714
      {
 
3715
      keyword =  word[1] ;      // pass keyword
 
3716
      writearg(keyword);
 
3717
      toupper(keyword);
 
3718
      if (!strcmp(keyword,"R4") || !strcmp(keyword,"REAL4"))
 
3719
        comprefdeminput.iformatflag = FORMATR4;
 
3720
      else if (!strcmp(keyword,"I2") || !strcmp(keyword,"SHORT"))
 
3721
        comprefdeminput.iformatflag = FORMATI2; // default
 
3722
      else if (!strcmp(keyword,"I2_BIGENDIAN") || 
 
3723
               !strcmp(keyword,"SHORT_BIGENDIAN"))
 
3724
        comprefdeminput.iformatflag = FORMATI2_BIGENDIAN;       // default
 
3725
      else if (!strcmp(keyword,"R8") || !strcmp(keyword,"REAL8"))
 
3726
        comprefdeminput.iformatflag = FORMATR8;
 
3727
      else
 
3728
        {
 
3729
        ERROR << "CRD_IN_FORMAT: input format "
 
3730
             <<  keyword
 
3731
             << " not known (R4 R8 I2 (native) SHORT_BIGENDIAN); line "
 
3732
             << linecnt << ".";
 
3733
        PRINT_ERROR(ERROR.get_str())
 
3734
        throw(keyword_error);
 
3735
        }
 
3736
      }
 
3737
 
 
3738
// **********************************************************************
 
3739
    else if (!strcmp(keyword,"CRD_IN_SIZE"))         // nrow ncols (lat lon)
 
3740
      {
 
3741
      comprefdeminput.demrows =  strtoul(word[1], NULL, BASE10);         // pass keyword [MA] atoi instead strtoul 
 
3742
      comprefdeminput.demcols =  strtoul(word[2], NULL, BASE10);         // pass keyword
 
3743
      writearg(comprefdeminput.demrows);
 
3744
      writearg(comprefdeminput.demcols);
 
3745
      }
 
3746
 
 
3747
// **********************************************************************
 
3748
    else if (!strcmp(keyword,"CRD_IN_DELTA"))        // degrees delta lat lon
 
3749
      {
 
3750
      comprefdeminput.demdeltalat =  atof(word[1]) ;    // pass keyword
 
3751
      keyword                     =  word[2] ;        // update keyword
 
3752
      writearg(comprefdeminput.demdeltalat);
 
3753
      writearg(keyword);
 
3754
      if (isdigit(keyword[0]) || keyword[0]=='.')    // likely to be 2 numbers
 
3755
        comprefdeminput.demdeltalon = atof(keyword);
 
3756
      else // default same gridsize
 
3757
        comprefdeminput.demdeltalon = comprefdeminput.demdeltalat;
 
3758
 
 
3759
      // ______ Store as radians ______
 
3760
      comprefdeminput.demdeltalat = deg2rad(comprefdeminput.demdeltalat);
 
3761
      comprefdeminput.demdeltalon = deg2rad(comprefdeminput.demdeltalon);
 
3762
      }
 
3763
 
 
3764
// **********************************************************************
 
3765
    else if (!strcmp(keyword,"CRD_IN_UL"))           // upperleft coordinates
 
3766
      {
 
3767
      char *pLast1, *pLast2 = NULL;
 
3768
      comprefdeminput.demlatleftupper = strtod(word[1], &pLast1); 
 
3769
                  comprefdeminput.demlonleftupper = strtod(word[2], &pLast2);
 
3770
      if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
3771
       {
 
3772
        ERROR << "CRD_IN_UL: "  << word[1] << " : " << word[2] << " are not valid.";
 
3773
        PRINT_ERROR(ERROR.get_str())
 
3774
        throw(keyword_error);
 
3775
       }
 
3776
      writearg(comprefdeminput.demlatleftupper);
 
3777
      writearg(comprefdeminput.demlonleftupper);
 
3778
      comprefdeminput.demlatleftupper = deg2rad(comprefdeminput.demlatleftupper);
 
3779
      comprefdeminput.demlonleftupper = deg2rad(comprefdeminput.demlonleftupper);
 
3780
      }
 
3781
 
 
3782
// **********************************************************************
 
3783
    else if (!strcmp(keyword,"CRD_IN_NODATA"))       // flag for no data
 
3784
      {
 
3785
      comprefdeminput.demnodata =  atof(word[1]) ;      // pass keyword
 
3786
      writearg(comprefdeminput.demnodata);
 
3787
      }
 
3788
 
 
3789
// **********************************************************************
 
3790
    else if (!strcmp(keyword,"CRD_INCLUDE_FE"))      // true: ref.pha incl. flat earth
 
3791
      {
 
3792
      keyword =  word[1] ;      // pass keyword
 
3793
      writearg(keyword);
 
3794
      toupper(keyword);
 
3795
      if (!strcmp(keyword,"OFF"))
 
3796
        comprefdeminput.includerefpha = false;
 
3797
      else if (!strcmp(keyword,"ON")    ||
 
3798
               !strncmp(keyword,"//",2) ||              // comment
 
3799
               !strncmp(keyword,"#",1)  ||              // comment
 
3800
               !(keyword[0] == '\0'))                   // no keyword
 
3801
        comprefdeminput.includerefpha = true;
 
3802
      else
 
3803
        {
 
3804
        comprefdeminput.includerefpha = false;
 
3805
        WARNING << "CRD_INCLUDE_FE: line: " << linecnt << ": unknown argument: "
 
3806
             << keyword 
 
3807
             << "; Set to OFF (computing pure topo phase w.r.t. flat earth).";
 
3808
       WARNING.print();
 
3809
       }
 
3810
      }
 
3811
 
 
3812
// **********************************************************************
 
3813
//    else if (!strcmp(keyword,"CRD_DENSE"))            // factor
 
3814
//      {
 
3815
//      comprefdeminput.extradense =  word[1] ;         // pass keyword
 
3816
//      writearg(comprefdeminput.extradense);
 
3817
//      }
 
3818
 
 
3819
// **********************************************************************
 
3820
    else if (!strcmp(keyword,"CRD_OUT_DEM"))          // name of output file
 
3821
      {
 
3822
      strcpy(comprefdeminput.fodem,  word[1] );         // pass keyword
 
3823
      writearg(comprefdeminput.fodem);
 
3824
      }
 
3825
 
 
3826
// **********************************************************************
 
3827
    else if (!strcmp(keyword,"CRD_OUT_DEMI"))          // name of output file
 
3828
      {
 
3829
      strcpy(comprefdeminput.fodemi,  word[1] );        // pass keyword
 
3830
      writearg(comprefdeminput.fodemi);
 
3831
      }
 
3832
 
 
3833
// **********************************************************************
 
3834
    else if (!strcmp(keyword,"CRD_OUT_FILE"))          // name of output file
 
3835
      {
 
3836
      strcpy(comprefdeminput.forefdem,  word[1] );      // pass keyword
 
3837
      writearg(comprefdeminput.forefdem);
 
3838
      }
 
3839
 
 
3840
// ___________ added by FvL      
 
3841
// **********************************************************************
 
3842
    else if (!strcmp(keyword,"CRD_OUT_H2PH"))          // name of output file
 
3843
      {
 
3844
      strcpy(comprefdeminput.foh2ph,  word[1] );        // pass keyword
 
3845
      writearg(comprefdeminput.foh2ph);
 
3846
      }
 
3847
// ___________ end added by FvL
 
3848
 
 
3849
// **********************************************************************
 
3850
    else if (!strcmp(keyword,"CRD_OUT_DEM_LP"))        // name of output file
 
3851
      {
 
3852
      strcpy(comprefdeminput.forefdemhei,  word[1] );   // pass keyword
 
3853
      writearg(comprefdeminput.forefdemhei);
 
3854
      }
 
3855
 
 
3856
 
 
3857
// **********************************************************************
 
3858
// *** SUBTRACTION OF REFERENCE DEM (phase)
 
3859
// **********************************************************************
 
3860
    else if (!strcmp(keyword,"SRD_OUT_CINT"))          // name of output file
 
3861
      {
 
3862
      strcpy(subtrrefdeminput.focint,  word[1] );       // pass keyword
 
3863
      writearg(subtrrefdeminput.focint);
 
3864
      }
 
3865
 
 
3866
// **********************************************************************
 
3867
    else if (!strcmp(keyword,"SRD_OFFSET"))          // Line Pixel
 
3868
      {
 
3869
      subtrrefdeminput.offsetL =  atoi(word[1]);        // pass keyword
 
3870
      subtrrefdeminput.offsetP =  atoi(word[2]);        // pass keyword
 
3871
      writearg(subtrrefdeminput.offsetL);
 
3872
      writearg(subtrrefdeminput.offsetP);
 
3873
      }
 
3874
 
 
3875
//  // **********************************************************************
 
3876
//  // *** ADDITION OF REFERENCE DEM (phase)
 
3877
//  // **********************************************************************
 
3878
//      else if (!strcmp(keyword,"ARD_OUT_CINT"))          // name of output file
 
3879
//        {
 
3880
//        addrefdeminput.focint =  word[1] ;    // pass keyword
 
3881
//        }
 
3882
 
 
3883
// **********************************************************************
 
3884
// *** UNWRAPPING
 
3885
// **********************************************************************
 
3886
    else if (!strcmp(keyword,"UW_METHOD"))  // method selector unwrapping
 
3887
      {                                               
 
3888
      keyword =  word[1] ;      // pass keyword
 
3889
      writearg(keyword);
 
3890
      toupper(keyword);
 
3891
      if (!strcmp(keyword,"RAMON"))
 
3892
        unwrapinput.method = uw_method1;
 
3893
      else if (!strcmp(keyword,"SNAPHU"))
 
3894
        unwrapinput.method = uw_method2;//   default
 
3895
      else if (!strcmp(keyword,"MCF_DLR"))
 
3896
        unwrapinput.method = uw_method3;
 
3897
      else
 
3898
        {
 
3899
        ERROR << "UW_METHOD: method "
 
3900
             <<  keyword
 
3901
             << " not known for unwrapping on line "
 
3902
             << linecnt << ".";
 
3903
        PRINT_ERROR(ERROR.get_str())
 
3904
        throw(keyword_error);
 
3905
        }
 
3906
      }
 
3907
 
 
3908
// **********************************************************************
 
3909
    else if (!strcmp(keyword,"UW_SEEDS"))             // position of seeds
 
3910
      {
 
3911
      keyword =  word[1] ;      // pass keyword
 
3912
      writearg(keyword);
 
3913
      if (isdigit(keyword[0]))
 
3914
        {
 
3915
         unwrapinput.deltaLseed = atoi(keyword);
 
3916
         keyword =  word[2] ;   // update keyword
 
3917
         writearg(keyword);
 
3918
         if (isdigit(keyword[0]))
 
3919
            unwrapinput.deltaPseed = atoi(keyword);
 
3920
         else
 
3921
            unwrapinput.deltaPseed = unwrapinput.deltaLseed;
 
3922
        }
 
3923
      else      // assume no numbers but filename with seeds
 
3924
        {
 
3925
         strcpy(unwrapinput.seedfile,keyword);
 
3926
        }
 
3927
       }
 
3928
 
 
3929
// **********************************************************************
 
3930
    else if (!strcmp(keyword,"UW_OUT_FILE"))          // filename output unwrapped int.
 
3931
      {
 
3932
      strcpy(unwrapinput.fouint,  word[1] );    // pass keyword
 
3933
      writearg(unwrapinput.fouint);
 
3934
      }
 
3935
 
 
3936
// **********************************************************************
 
3937
    else if (!strcmp(keyword,"UW_OUT_FORMAT"))       // output format
 
3938
      {
 
3939
      keyword =  word[1] ;      // pass keyword
 
3940
      writearg(keyword);
 
3941
      toupper(keyword);
 
3942
      if (!strcmp(keyword,"R4") || !strcmp(keyword,"REAL4"))
 
3943
        unwrapinput.oformatflag = FORMATR4;
 
3944
      else if (!strcmp(keyword,"CR4") || !strcmp(keyword,"COMPLEXR4"))
 
3945
        {
 
3946
        WARNING.print("UW_OUT_FORMAT = CR4 --> Using hgt format");
 
3947
        unwrapinput.oformatflag = FORMATHGT;// default
 
3948
        }
 
3949
      else if (!strcmp(keyword,"HGT"))
 
3950
        unwrapinput.oformatflag = FORMATHGT;// default
 
3951
      else
 
3952
        {
 
3953
        unwrapinput.oformatflag = FORMATHGT;// default
 
3954
        WARNING << "UW_OUT_FORMAT: output format "
 
3955
             <<  keyword
 
3956
             << " not known (R4 or HGT, using HGT); line "
 
3957
             << linecnt << ".";
 
3958
        WARNING.print();
 
3959
        }
 
3960
      }
 
3961
 
 
3962
// **********************************************************************
 
3963
    else if (!strcmp(keyword,"UW_OUT_REGIONS"))       // filename output regions
 
3964
      {
 
3965
      strcpy(unwrapinput.foregions,  word[1] );         // pass keyword
 
3966
      writearg(unwrapinput.foregions);
 
3967
      }
 
3968
 
 
3969
// **********************************************************************
 
3970
    else if (!strcmp(keyword,"UW_SNAPHU_MODE"))       // filename output regions
 
3971
      {
 
3972
      keyword =  word[1] ;      // pass keyword
 
3973
      writearg(keyword);
 
3974
      toupper(keyword);
 
3975
      if (!strcmp(keyword,"TOPO"))
 
3976
        strcpy(unwrapinput.snaphu_mode,"TOPO");        // default TOPO
 
3977
      else if (!strcmp(keyword,"DEFO"))
 
3978
        strcpy(unwrapinput.snaphu_mode,"DEFO");
 
3979
      else if (!strcmp(keyword,"SMOOTH"))
 
3980
        strcpy(unwrapinput.snaphu_mode,"SMOOTH");
 
3981
      else if (!strcmp(keyword,"NOSTATCOSTS"))
 
3982
        strcpy(unwrapinput.snaphu_mode,"NOSTATCOSTS");
 
3983
      else
 
3984
        {
 
3985
        ERROR << "UW_SNAPHU_MODE: "
 
3986
             <<  keyword
 
3987
             << " not known for unwrapping on line "
 
3988
             << linecnt << ".";
 
3989
        PRINT_ERROR(ERROR.get_str())
 
3990
        throw(keyword_error);
 
3991
        }
 
3992
      }
 
3993
 
 
3994
// **********************************************************************
 
3995
    else if (!strcmp(keyword,"UW_SNAPHU_INIT"))
 
3996
      {
 
3997
      keyword =  word[1] ;      // pass keyword
 
3998
      writearg(keyword);
 
3999
      toupper(keyword);
 
4000
      if (!strcmp(keyword,"MST"))
 
4001
        strcpy(unwrapinput.snaphu_init,"MST");     // default mst
 
4002
      else if (!strcmp(keyword,"MCF"))
 
4003
        strcpy(unwrapinput.snaphu_init,"MCF");
 
4004
      else
 
4005
        {
 
4006
        WARNING << "UW_SNAPHU_INIT: "
 
4007
             <<  keyword
 
4008
             << " not known for unwrapping on line "
 
4009
             << linecnt << " (using MST).";
 
4010
        WARNING.print();
 
4011
        }
 
4012
      }
 
4013
 
 
4014
// **********************************************************************
 
4015
    else if (!strcmp(keyword,"UW_SNAPHU_LOG"))
 
4016
      {
 
4017
      strcpy(unwrapinput.snaphu_log,  word[1] );        // pass keyword
 
4018
      writearg(unwrapinput.snaphu_log);
 
4019
      //strcpy(unwrapinput.snaphu_log,"-l ");
 
4020
      //strcat(unwrapinput.snaphu_log,keyword);
 
4021
      }
 
4022
 
 
4023
// **********************************************************************
 
4024
    else if (!strcmp(keyword,"UW_SNAPHU_COH"))
 
4025
      {
 
4026
      strcpy(unwrapinput.snaphu_coh,  word[1] );        // pass keyword
 
4027
      writearg(unwrapinput.snaphu_coh);
 
4028
      }
 
4029
 
 
4030
// **********************************************************************
 
4031
    else if (!strcmp(keyword,"UW_SNAPHU_VERBOSE"))
 
4032
      {
 
4033
      keyword =  word[1] ;      // pass keyword
 
4034
      writearg(keyword);
 
4035
      toupper(keyword);
 
4036
      if (!strcmp(keyword,"OFF"))
 
4037
        strcpy(unwrapinput.snaphu_verbose,"FALSE");
 
4038
      else if (!strcmp(keyword,"ON")    ||
 
4039
               !strncmp(keyword,"//",2) ||              // comment
 
4040
               !strncmp(keyword,"#",1)  ||              // comment
 
4041
               !(keyword[0] == '\0'))                   // no keyword
 
4042
        strcpy(unwrapinput.snaphu_verbose,"TRUE");
 
4043
      else
 
4044
        {
 
4045
        strcpy(unwrapinput.snaphu_verbose,"TRUE");
 
4046
        WARNING << "UW_SNAPHU_VERBOSE: line: " 
 
4047
             << linecnt << ": unknown argument: " << keyword 
 
4048
             << "; Set to ON.";
 
4049
       WARNING.print();
 
4050
        }
 
4051
      }
 
4052
 
 
4053
    else if (!strcmp(keyword,"UW_SNAPHU_NTILEROW"))
 
4054
      {
 
4055
             unwrapinput.ntilerow =  atoi(word[1]) ;    // pass keyword
 
4056
             writearg(unwrapinput.ntilerow);
 
4057
       if (unwrapinput.ntilerow > 50)
 
4058
         {
 
4059
          WARNING.print("UW_SNAPHU_NTILEROW > 100 tiles, is this okay? ");
 
4060
         } 
 
4061
      INFO << "UW_SNAPHU_NTILEROW: \t " 
 
4062
           << unwrapinput.ntilerow;
 
4063
      INFO.print();
 
4064
      }
 
4065
 
 
4066
    else if (!strcmp(keyword,"UW_SNAPHU_NTILECOL"))
 
4067
      {
 
4068
       unwrapinput.ntilecol =  atoi(word[1]) ;  // pass keyword
 
4069
       writearg(unwrapinput.ntilecol);
 
4070
       if (unwrapinput.ntilecol > 50)
 
4071
       {
 
4072
         WARNING.print("UW_SNAPHU_NTILECOL > 100 tiles, is this okay? ");
 
4073
       }
 
4074
     
 
4075
       INFO << "UW_SNAPHU_NTILECOL: \t "
 
4076
            << unwrapinput.ntilecol;
 
4077
       INFO.print();
 
4078
      }   
 
4079
 
 
4080
    else if (!strcmp(keyword,"UW_SNAPHU_ROWOVRLP"))
 
4081
      {
 
4082
        unwrapinput.rowovrlp =  atoi(word[1]) ;         // pass keyword
 
4083
        writearg(unwrapinput.rowovrlp);
 
4084
        INFO << "UW_SNAPHU_ROWOVRLP: \t "
 
4085
             << unwrapinput.rowovrlp;
 
4086
        INFO.print();
 
4087
      }   
 
4088
 
 
4089
    else if (!strcmp(keyword,"UW_SNAPHU_COLOVRLP"))
 
4090
      {
 
4091
        unwrapinput.colovrlp =  atoi(word[1]) ;         // pass keyword
 
4092
        writearg(unwrapinput.colovrlp);
 
4093
        INFO << "UW_SNAPHU_COLOVRLP: \t "
 
4094
             << unwrapinput.colovrlp;
 
4095
        INFO.print();
 
4096
      }   
 
4097
 
 
4098
    else if (!strcmp(keyword,"UW_SNAPHU_NPROC"))
 
4099
      {
 
4100
        unwrapinput.nproc =  atoi(word[1]) ;    // pass keyword
 
4101
        writearg(unwrapinput.nproc);
 
4102
        if (unwrapinput.ntilecol > 2)
 
4103
        {
 
4104
          WARNING.print("UW_SNAPHU_NPROC > 2CPUs, do you have a cluster?");
 
4105
        }
 
4106
      
 
4107
        INFO << "UW_SNAPHU_NPROC: \t "
 
4108
             << unwrapinput.ntilecol;
 
4109
        INFO.print();
 
4110
      }   
 
4111
 
 
4112
    else if (!strcmp(keyword,"UW_SNAPHU_TILECOSTTHRESH"))
 
4113
      {
 
4114
        unwrapinput.tilecostthresh =  atoi(word[1]) ;   // pass keyword
 
4115
        writearg(unwrapinput.tilecostthresh);
 
4116
        if (unwrapinput.ntilecol > 500)
 
4117
        {
 
4118
          WARNING.print("UW_SNAPHU_TILECOSTTHRESH > 500, do you have a cluster?");
 
4119
        }
 
4120
      
 
4121
        INFO << "UW_SNAPHU_TILECOSTTHRESH: \t "
 
4122
             << unwrapinput.tilecostthresh;
 
4123
        INFO.print();
 
4124
      }   
 
4125
    else if (!strcmp(keyword,"UW_SNAPHU_DUMPONLYCONF")) //
 
4126
      {
 
4127
      keyword =  word[1] ;      // pass keyword
 
4128
      writearg(keyword);
 
4129
      toupper(keyword);
 
4130
      if (!strcmp(keyword,"OFF"))
 
4131
        unwrapinput.snaphu_dumponlyconf=false;
 
4132
      else if (!strcmp(keyword,"ON")    ||
 
4133
               !strncmp(keyword,"//",2) ||              // comment
 
4134
               !strncmp(keyword,"#",1)  ||              // comment
 
4135
               !(keyword[0] == '\0'))                   // no keyword
 
4136
        unwrapinput.snaphu_dumponlyconf=true;
 
4137
      else 
 
4138
        {
 
4139
        unwrapinput.snaphu_dumponlyconf=true;
 
4140
        WARNING << "UW_SNAPHU_DUMPONLYCONF: line: " 
 
4141
             << linecnt << ": unknown argument: " << keyword 
 
4142
             << "; Set to ON.";
 
4143
       WARNING.print();
 
4144
        }
 
4145
      }
 
4146
 
 
4147
// **********************************************************************
 
4148
// *** SLANT to HEIGHT CONVERSION
 
4149
// **********************************************************************
 
4150
    else if (!strcmp(keyword,"S2H_METHOD"))           // method selector slant2height
 
4151
      {                                               
 
4152
      keyword =  word[1] ;      // pass keyword
 
4153
      writearg(keyword);
 
4154
      toupper(keyword);
 
4155
      if (!strcmp(keyword,"SCHWABISCH"))
 
4156
        slant2hinput.method = s2h_schwabisch;
 
4157
      else if (!strcmp(keyword,"AMBIGUITY"))
 
4158
        slant2hinput.method = s2h_ambiguity;
 
4159
      else if (!strcmp(keyword,"RODRIGUEZ"))
 
4160
        slant2hinput.method = s2h_rodriguez;
 
4161
      else
 
4162
        {
 
4163
        ERROR << "S2H_METHOD: method "
 
4164
             <<  keyword
 
4165
             << " not known for slant to height conversion, line "
 
4166
             << linecnt << ".";
 
4167
        PRINT_ERROR(ERROR.get_str())
 
4168
        throw(keyword_error);
 
4169
        }
 
4170
      }
 
4171
 
 
4172
// **********************************************************************
 
4173
    else if (!strcmp(keyword,"S2H_NPOINTS"))          // number of points to use
 
4174
      {
 
4175
      slant2hinput.Npoints =  atoi(word[1]) ;   // pass keyword
 
4176
      writearg(slant2hinput.Npoints);
 
4177
      }
 
4178
 
 
4179
// **********************************************************************
 
4180
    else if (!strcmp(keyword,"S2H_DEGREE1D"))         // degree of 1d polynomial
 
4181
      {
 
4182
      slant2hinput.degree1d =  atoi(word[1]) ;  // pass keyword
 
4183
      writearg(slant2hinput.degree1d);
 
4184
      }
 
4185
 
 
4186
// **********************************************************************
 
4187
    else if (!strcmp(keyword,"S2H_DEGREE2D"))          // degree of 2d polynomial
 
4188
      {
 
4189
      slant2hinput.degree2d =  atoi(word[1]) ;  // pass keyword
 
4190
      writearg(slant2hinput.degree2d);
 
4191
      }
 
4192
 
 
4193
// **********************************************************************
 
4194
    else if (!strcmp(keyword,"S2H_NHEIGHTS"))         // #heights to evaluate ref.pha
 
4195
      {
 
4196
      slant2hinput.Nheights =  atoi(word[1]) ;  // pass keyword
 
4197
      writearg(slant2hinput.Nheights);
 
4198
      }
 
4199
 
 
4200
// **********************************************************************
 
4201
    else if (!strcmp(keyword,"S2H_OUT_HEI"))          // filename output height
 
4202
      {
 
4203
      strcpy(slant2hinput.fohei,  word[1] );    // pass keyword
 
4204
      writearg(slant2hinput.fohei);
 
4205
      }
 
4206
 
 
4207
// **********************************************************************
 
4208
    else if (!strcmp(keyword,"S2H_OUT_PHI"))          // filename output latitude
 
4209
      {
 
4210
      strcpy(slant2hinput.fophi,  word[1] );    // pass keyword
 
4211
      writearg(slant2hinput.fophi);
 
4212
      }
 
4213
 
 
4214
// **********************************************************************
 
4215
    else if (!strcmp(keyword,"S2H_OUT_LAM"))          // filename output longitude
 
4216
      {
 
4217
      strcpy(slant2hinput.folam,  word[1] );    // pass keyword
 
4218
      writearg(slant2hinput.folam);
 
4219
      }
 
4220
 
 
4221
// **********************************************************************
 
4222
// *** GEOCODING
 
4223
// **********************************************************************
 
4224
//      else if (!strcmp(keyword,"GEO_METHOD"))
 
4225
//        {
 
4226
//        geocodeinput.method =  word[1] ;      // pass keyword
 
4227
//        }
 
4228
 
 
4229
// **********************************************************************
 
4230
    else if (!strcmp(keyword,"GEO_OUT_PHI"))          // output file latitude
 
4231
      {
 
4232
      strcpy(geocodeinput.fophi,  word[1] );    // pass keyword
 
4233
      writearg(geocodeinput.fophi);
 
4234
      }
 
4235
 
 
4236
// **********************************************************************
 
4237
    else if (!strcmp(keyword,"GEO_OUT_LAM"))          // output file longitude
 
4238
      {
 
4239
      strcpy(geocodeinput.folam,  word[1] );    // pass keyword
 
4240
      writearg(geocodeinput.folam);
 
4241
      }
 
4242
 
 
4243
 
 
4244
// ____ start added by HB ____
 
4245
// **********************************************************************
 
4246
// *** ESTORBITS 
 
4247
// **********************************************************************
 
4248
    else if (!strcmp(keyword,"EO_METHOD"))
 
4249
      {
 
4250
        keyword = word[1];
 
4251
        writearg(keyword);
 
4252
        toupper(keyword);
 
4253
        if (!strcmp(keyword,"LSQ"))
 
4254
          estorbitsinput.method = eo_lsq;
 
4255
        else if (!strcmp(keyword,"GRIDSEARCH"))
 
4256
          estorbitsinput.method = eo_gridsearch;
 
4257
        else
 
4258
          {
 
4259
            ERROR << "EO_METHOD: unknown method " << keyword 
 
4260
                  << ", line " << linecnt << ".";
 
4261
            PRINT_ERROR(ERROR.get_str())
 
4262
              throw(keyword_error);
 
4263
          }
 
4264
      }
 
4265
 
 
4266
// **********************************************************************
 
4267
    else if (!strcmp(keyword,"EO_IN_DEM_LP"))
 
4268
      {
 
4269
        strcpy(estorbitsinput.fiheightmap, word[1]);
 
4270
        writearg(estorbitsinput.fiheightmap);
 
4271
      }
 
4272
 
 
4273
// **********************************************************************
 
4274
    else if (!strcmp(keyword,"EO_OUT_RES"))
 
4275
      {
 
4276
        strcpy(estorbitsinput.foresiduals, word[1]);
 
4277
        writearg(estorbitsinput.foresiduals);
 
4278
      }
 
4279
 
 
4280
// **********************************************************************
 
4281
    else if (!strcmp(keyword,"EO_WEIGHTING"))
 
4282
      {
 
4283
        keyword = word[1];
 
4284
        writearg(keyword);
 
4285
        toupper(keyword);
 
4286
        if (!strcmp(keyword,"NONE"))
 
4287
          estorbitsinput.weighting = eo_noweighting;
 
4288
        else if (!strcmp(keyword,"COH"))
 
4289
          estorbitsinput.weighting = eo_coh;
 
4290
        else if (!strcmp(keyword,"COH2"))
 
4291
          estorbitsinput.weighting = eo_coh2;
 
4292
        else if (!strcmp(keyword,"PDF"))
 
4293
          estorbitsinput.weighting = eo_pdf;
 
4294
        else
 
4295
          {
 
4296
            ERROR << "EO_WEIGHTING: unknown weighting scheme " << keyword
 
4297
                  << ", line " << linecnt << ".";
 
4298
            PRINT_ERROR(ERROR.get_str())
 
4299
              throw(keyword_error);
 
4300
          }
 
4301
      }
 
4302
 
 
4303
// **********************************************************************
 
4304
    else if (!strcmp(keyword,"EO_NPOINTS"))
 
4305
      {
 
4306
        estorbitsinput.nobs = atoi(word[1]);
 
4307
        writearg(estorbitsinput.nobs);
 
4308
      }
 
4309
 
 
4310
// **********************************************************************
 
4311
    else if (!strcmp(keyword,"EO_IN_POS"))
 
4312
      {
 
4313
        strcpy(estorbitsinput.ifpositions,word[1] ); 
 
4314
        writearg(estorbitsinput.ifpositions);
 
4315
      }
 
4316
 
 
4317
// **********************************************************************
 
4318
    else if (!strcmp(keyword,"EO_THRESHOLD"))
 
4319
      {
 
4320
        estorbitsinput.threshold = atof(word[1]);
 
4321
        writearg(estorbitsinput.threshold);
 
4322
        if (estorbitsinput.threshold > 1)
 
4323
          {
 
4324
            ERROR << "EO_THRESHOLD: threshold > 1, line " << linecnt << ".";
 
4325
            PRINT_ERROR(ERROR.get_str())
 
4326
              throw(keyword_error);
 
4327
          }
 
4328
      }
 
4329
 
 
4330
// **********************************************************************
 
4331
    else if (!strcmp(keyword,"EO_MAXITER"))
 
4332
      {
 
4333
        estorbitsinput.maxiter = atoi(word[1]);
 
4334
        writearg(estorbitsinput.maxiter);
 
4335
      }
 
4336
 
 
4337
// **********************************************************************
 
4338
    else if (!strcmp(keyword,"EO_K_ALPHA"))
 
4339
      {
 
4340
        estorbitsinput.k_alpha = atof(word[1]);
 
4341
        writearg(estorbitsinput.k_alpha);
 
4342
        if (estorbitsinput.k_alpha < 0)
 
4343
          {
 
4344
            ERROR << "EO_K_ALPHA: critical value < 0, line " << linecnt << ".";
 
4345
            PRINT_ERROR(ERROR.get_str())
 
4346
              throw(keyword_error);
 
4347
          }
 
4348
      }
 
4349
 
 
4350
// **********************************************************************
 
4351
    else if (!strcmp(keyword,"EO_SEARCHSPACE"))
 
4352
      {                                               
 
4353
        char *pLast1, *pLast2 = NULL;
 
4354
        estorbitsinput.maxfringesaz = strtoul(word[1], &pLast1, BASE10); 
 
4355
        estorbitsinput.maxfringesrg = strtoul(word[2], &pLast2, BASE10);
 
4356
        if ( pLast1 == word[1] || pLast2 == word[2] ) // fails to convert one of them to double.
 
4357
          {
 
4358
            ERROR << "EO_SEARCHSPACE: "  << word[1] << " : " 
 
4359
                  << word[2] << " are not valid.";
 
4360
            PRINT_ERROR(ERROR.get_str())
 
4361
              throw(keyword_error);
 
4362
          }
 
4363
        writearg(estorbitsinput.maxfringesaz);
 
4364
        writearg(estorbitsinput.maxfringesrg);
 
4365
        if (estorbitsinput.maxfringesaz > 500 || estorbitsinput.maxfringesrg > 500)
 
4366
          {
 
4367
            WARNING << "EO_SEARCHSPACE: Parameters (" << estorbitsinput.maxfringesaz
 
4368
                    << "," << estorbitsinput.maxfringesrg << ") appear to be very high.";
 
4369
            WARNING.print();
 
4370
          }
 
4371
      }
 
4372
 
 
4373
// **********************************************************************
 
4374
    else if (!strcmp(keyword,"EO_REFORBIT"))
 
4375
      {
 
4376
        strcpy(estorbitsinput.reforbitfile, word[1]);
 
4377
        writearg(estorbitsinput.reforbitfile);
 
4378
      }
 
4379
 
 
4380
// **********************************************************************
 
4381
    else if (!strcmp(keyword,"EO_OUT_DATA"))
 
4382
      {
 
4383
        strcpy(estorbitsinput.foobsdata, word[1]);
 
4384
        writearg(estorbitsinput.foobsdata);
 
4385
      }
 
4386
 
 
4387
// **********************************************************************
 
4388
    else if (!strcmp(keyword,"EO_DEGREE"))
 
4389
      {
 
4390
        estorbitsinput.poldegree = atoi(word[1]);
 
4391
        writearg(estorbitsinput.poldegree);
 
4392
      }
 
4393
 
 
4394
// **********************************************************************
 
4395
    else if (!strcmp(keyword,"EO_CONSTRAIN"))
 
4396
      {
 
4397
        int16 npar = atoi(word[1]);
 
4398
        writearg(npar);
 
4399
        if (npar==0)
 
4400
          estorbitsinput.constrained = false;
 
4401
        else
 
4402
          {
 
4403
            estorbitsinput.constraints = matrix<int16>(npar,2);
 
4404
            for (uint i=0; i<npar; i++)
 
4405
              {
 
4406
                keyword = word[2+i];
 
4407
                toupper(keyword);
 
4408
                int16 component;
 
4409
                int16 deriv = -1;
 
4410
                if (!strncmp(keyword, "BPAR", 4))
 
4411
                  {
 
4412
                    component = 0;
 
4413
                    deriv = int(keyword[4])-48;  // char2int
 
4414
                  }
 
4415
                else if (!strncmp(keyword, "BPERP", 5))
 
4416
                  {
 
4417
                    component = 1;
 
4418
                    deriv = int(keyword[5])-48;  // char2int
 
4419
                  }
 
4420
                if (deriv<0)
 
4421
                  {
 
4422
                    ERROR << "EO_CONSTRAIN: parameter "
 
4423
                          << keyword
 
4424
                          << " not interpretable for orbit estimation, line "
 
4425
                          << linecnt << ".";
 
4426
                    PRINT_ERROR(ERROR.get_str())
 
4427
                      throw(keyword_error);
 
4428
                  }
 
4429
                else if (deriv>15)
 
4430
                  {
 
4431
                    ERROR << "EO_CONSTRAIN: degree of parameter "
 
4432
                          << keyword
 
4433
                          << " is too high, line "
 
4434
                          << linecnt << ".";
 
4435
                    PRINT_ERROR(ERROR.get_str())
 
4436
                      throw(keyword_error);
 
4437
                  }
 
4438
                else
 
4439
                  {
 
4440
                    estorbitsinput.constraints(i,0) = component;
 
4441
                    estorbitsinput.constraints(i,1) = deriv;
 
4442
                  }
 
4443
              }
 
4444
          }
 
4445
      }
 
4446
// ____ end added by HB ____    
 
4447
 
 
4448
 
 
4449
// **********************************************************************
 
4450
// Assume wrong keyword, but if it starts with //, a c, or comment
 
4451
// then continue with a warning, no blank between key and arg
 
4452
// **********************************************************************
 
4453
    else if (!strncmp(keyword,"COMMENT",7) ||   // assume user wanted to comment out
 
4454
             !strncmp(keyword,"C",1))           // but forgot a space
 
4455
      {
 
4456
      WARNING << "Obsolete or unknown keyword: \"" << keyword 
 
4457
           << "\" at line: " << linecnt
 
4458
           << ". (Interpreted as comment, ignored)";
 
4459
      WARNING.print();
 
4460
      }
 
4461
    // ______ Really cannot make anything from your input ______
 
4462
    else
 
4463
      {
 
4464
      //ERROR << "Unknown keyword: \"" << keyword 
 
4465
      //     << "\" at line: " << linecnt << ".";
 
4466
      //PRINT_ERROR(ERROR.get_str())
 
4467
      //throw(keyword_error);
 
4468
      WARNING << "Unknown keyword: \"" << keyword 
 
4469
           << "\" at line: " << linecnt << ".";
 
4470
      WARNING.print();
 
4471
      }
 
4472
    //optionsfile.getline(eachline,4*ONE27,'\n');               // goto next line. [MA] needs debug if the line is long loops forever.
 
4473
    } // end while (file)
 
4474
 
 
4475
 
 
4476
 
 
4477
 
 
4478
 
 
4479
 
 
4480
// ====== Check input/ info to screen ======
 
4481
  checkgeneral(generalinput, onlyprocess);              // also repair onlyprocess
 
4482
  INFO << "LISTINPUT: \tAppend input to logfile: \t" << listinput;
 
4483
  INFO.print();
 
4484
 
 
4485
 
 
4486
// ______ info ELLIPSOID card, compute and fill e2, e2b ______
 
4487
  ellipsinput.showdata();
 
4488
 
 
4489
 
 
4490
// ====== Check input of step reading info from files ======
 
4491
  if (generalinput.process[pr_m_readfiles])
 
4492
    checkreadfiles(m_readfilesinput, MASTERID);         // check mandatory cards
 
4493
 
 
4494
  if (generalinput.process[pr_s_readfiles])
 
4495
    checkreadfiles(s_readfilesinput, SLAVEID);          // check mandatory cards
 
4496
 
 
4497
 
 
4498
// ====== Check input of step conversion slc to raw ======
 
4499
  if (generalinput.process[pr_m_crop])
 
4500
    {
 
4501
    checkcrop(m_cropinput, MASTERID);
 
4502
    if (!strcmp(s_cropinput.fileout1,m_cropinput.fileout1))
 
4503
      {
 
4504
      PRINT_ERROR(
 
4505
      "code 301: same name outputfile CROP_OUT for master and slave not allowed.")
 
4506
      throw(keyword_error);
 
4507
      }
 
4508
    if (generalinput.overwrit)
 
4509
      if (existed(m_cropinput.fileout1))
 
4510
        {
 
4511
        INFO << "OVERWRIT: file " << m_cropinput.fileout1 
 
4512
             << " will be overwritten.";
 
4513
        INFO.print();
 
4514
        }
 
4515
    }
 
4516
 
 
4517
  if (generalinput.process[pr_s_crop])
 
4518
    {
 
4519
    checkcrop(s_cropinput, SLAVEID);
 
4520
    if (!strcmp(s_cropinput.fileout1,m_cropinput.fileout1))
 
4521
      {
 
4522
      PRINT_ERROR(
 
4523
      "code 301: same name outputfile CROP_OUT for master and slave not allowed.")
 
4524
      throw(keyword_error);
 
4525
      }
 
4526
    if (generalinput.overwrit)
 
4527
      if (existed(s_cropinput.fileout1))
 
4528
        {
 
4529
        INFO << "OVERWRIT: file " << s_cropinput.fileout1 
 
4530
             << " will be overwritten.";
 
4531
        INFO.print();
 
4532
        }
 
4533
    }
 
4534
 
 
4535
//____RaffaeleNutricato START MODIFICATION SECTION 10
 
4536
// ====== Check input of step oversample master======
 
4537
  if (generalinput.process[pr_m_oversample])
 
4538
    {
 
4539
    checkoversample(m_oversample, MASTERID);
 
4540
    }
 
4541
// ====== Check input of step oversampling slave ======
 
4542
  if (generalinput.process[pr_s_oversample])
 
4543
    {
 
4544
    checkoversample(s_oversample, SLAVEID);
 
4545
    }
 
4546
//____RaffaeleNutricato END MODIFICATION SECTION 10
 
4547
 
 
4548
 
 
4549
// ====== Check input of step porbits ======
 
4550
  if (generalinput.process[pr_m_porbits])
 
4551
    checkporbits(porbitsinput, MASTERID);
 
4552
  if (generalinput.process[pr_s_porbits])
 
4553
    checkporbits(porbitsinput, SLAVEID);
 
4554
 
 
4555
 
 
4556
  // ____ start added by HB ____
 
4557
  // ====== Check input of steps m_modorb and s_modorb ======
 
4558
  if (generalinput.process[pr_m_morbits])
 
4559
    {
 
4560
      // ______ determine polynomial degree => number of parameters ______
 
4561
      uint npar=2;
 
4562
      for (int16 i=9; i>=0; i--)
 
4563
        {
 
4564
        if (morbitsinputmaster.coeff(i,0)!=0 || morbitsinputmaster.coeff(i,1)!=0)
 
4565
          {
 
4566
            npar = 2*(i+1);
 
4567
            break;
 
4568
          }
 
4569
        }
 
4570
 
 
4571
      // ______ resize coefficient matrices ______
 
4572
      morbitsinputmaster.coeff.setdata(npar/2,0,morbitsinputmaster.coeff.getdata(window(0,npar/2-1,1,1)));
 
4573
      matrix<real8> temp = morbitsinputmaster.coeff.getdata(window(0,npar-1,0,0));
 
4574
      morbitsinputmaster.coeff.resize(npar,1);
 
4575
      morbitsinputmaster.coeff = temp; 
 
4576
      for (int p=0; p<npar; p++)
 
4577
        {
 
4578
          INFO << "MODORB master coefficient (" << p << "): " << morbitsinputmaster.coeff(p,0);
 
4579
          INFO.print();
 
4580
        }
 
4581
    }
 
4582
  if (generalinput.process[pr_s_morbits])
 
4583
    {
 
4584
      // ______ determine polynomial degree => number of parameters ______
 
4585
      uint npar=2;
 
4586
      for (int16 i=9; i>=0; i--)
 
4587
        if (morbitsinputslave.coeff(i,0)!=0 || morbitsinputslave.coeff(i,1)!=0)
 
4588
          {
 
4589
            npar = 2*(i+1);
 
4590
            break;
 
4591
          }
 
4592
 
 
4593
      // ______ resize coefficient matrices ______
 
4594
      morbitsinputslave.coeff.setdata(npar/2,0,morbitsinputslave.coeff.getdata(window(0,npar/2-1,1,1)));
 
4595
      matrix<real8> temp = morbitsinputslave.coeff.getdata(window(0,npar-1,0,0));
 
4596
      morbitsinputslave.coeff.resize(npar,1);
 
4597
      morbitsinputslave.coeff = temp; 
 
4598
      for (int p=0; p<npar; p++)
 
4599
        {
 
4600
          INFO << "MODORB slave coefficient (" << p << "): " << morbitsinputslave.coeff(p,0);
 
4601
          INFO.print();
 
4602
        }
 
4603
    }
 
4604
  // ____ end added by HB ____
 
4605
 
 
4606
 
 
4607
// ====== Check input of SIMAMP step master====== [MA]
 
4608
if (generalinput.process[pr_m_simamp])
 
4609
  {
 
4610
  checksimamp(simampinput);
 
4611
  }
 
4612
 
 
4613
// ====== Check input of MTIMING step master====== [MA] rev.2
 
4614
if (generalinput.process[pr_m_mtiming])
 
4615
  {
 
4616
    if (mtiminginput.method == def_mte_method-999) // see at defaults, no method card used
 
4617
      {
 
4618
      mtiminginput.method = def_mte_method;           // default method
 
4619
      INFO.print("Default method will be used for MASTER TIMING ERROR estimation.");
 
4620
      }
 
4621
    if (specified(mtiminginput.ifpositions))         // filename specified
 
4622
      {
 
4623
      if (mtiminginput.Nwin != def_mte_nwin+999)      // something is specified
 
4624
        {
 
4625
        WARNING << "MTE_NWIN: \t" << mtiminginput.Nwin
 
4626
             << " ignored due to existence of input file (MTE_IN_POS) "
 
4627
             << mtiminginput.ifpositions;
 
4628
        WARNING.print();
 
4629
        }
 
4630
      mtiminginput.Nwin = filelines(mtiminginput.ifpositions);
 
4631
      }
 
4632
    else if (mtiminginput.Nwin == def_mte_nwin+999)   // no inputfile, default
 
4633
      {
 
4634
      mtiminginput.Nwin = def_mte_nwin;
 
4635
      INFO.print("Default number of windows will be used for MASTER TIMING ERROR estimation.");
 
4636
      }
 
4637
  checkmtiming(mtiminginput);
 
4638
  }
 
4639
 
 
4640
// ====== Check input of step azimuth filtering ======
 
4641
  if (generalinput.process[pr_m_filtazi] ||
 
4642
      generalinput.process[pr_s_filtazi])
 
4643
    {
 
4644
    // ______ Set defaults ______
 
4645
    if (filtaziinput.overlap == -1)
 
4646
      filtaziinput.overlap = filtaziinput.fftlength/8;  // default
 
4647
    // ______ Check input ______
 
4648
    if (generalinput.process[pr_m_filtazi] &&
 
4649
        generalinput.process[pr_s_filtazi])
 
4650
      checkfiltazi(filtaziinput,MASTERID+SLAVEID);
 
4651
    else if (generalinput.process[pr_m_filtazi])
 
4652
      checkfiltazi(filtaziinput,MASTERID);
 
4653
    else if (generalinput.process[pr_s_filtazi])
 
4654
      checkfiltazi(filtaziinput,SLAVEID);
 
4655
    else 
 
4656
      {
 
4657
      PRINT_ERROR("PANIC, this cannot be")
 
4658
      throw(keyword_error);
 
4659
      }
 
4660
    }
 
4661
 
 
4662
// ====== Check input of step range filtering ======
 
4663
  if (generalinput.process[pr_m_filtrange])
 
4664
    {
 
4665
    // ______ Check defaults ______
 
4666
    if (filtrangeinput.fftlength==-999) // not specified
 
4667
      {
 
4668
      if (filtrangeinput.method==rf_adaptive)
 
4669
        filtrangeinput.fftlength=64;            // default
 
4670
      else if (filtrangeinput.method==rf_porbits)
 
4671
        filtrangeinput.fftlength=1024;          // default
 
4672
      }
 
4673
    checkfiltrange(filtrangeinput);
 
4674
    }
 
4675
 
 
4676
// ====== Check input of reserved EXTRA step master/slave ======
 
4677
  if (generalinput.process[pr_m_EXTRA])
 
4678
    {
 
4679
    PRINT_ERROR("extra step master not implemented.")
 
4680
    throw(keyword_error);
 
4681
    }
 
4682
  if (generalinput.process[pr_s_EXTRA])
 
4683
    {
 
4684
    PRINT_ERROR("extra step slave not implemented.")
 
4685
    throw(keyword_error);
 
4686
    }
 
4687
 
 
4688
 
 
4689
// ====== Check input of step coarse (orbits) ======
 
4690
// ______ no checks required. (no cards as well)
 
4691
  if (generalinput.process[pr_i_coarse])
 
4692
    {
 
4693
    ; // do nothing
 
4694
    }
 
4695
 
 
4696
 
 
4697
// ====== Check coarse coregistration based on correlation ======
 
4698
// ______ Check + repair method selector coarse correlation ______
 
4699
  if (generalinput.process[pr_i_coarse2])               // correlation
 
4700
    {
 
4701
    if (coarsecorrinput.method == def_cc_method-999) // see at defaults, no method card used
 
4702
      {
 
4703
      coarsecorrinput.method = def_cc_method;           // default method
 
4704
      INFO.print("Default method will be used for coarse coregistration.");
 
4705
      }
 
4706
    if (specified(coarsecorrinput.ifpositions))         // filename specified
 
4707
      {
 
4708
      if (coarsecorrinput.Nwin != def_cc_nwin+999)      // something is specified
 
4709
        {
 
4710
        WARNING << "CC_NWIN: \t" << coarsecorrinput.Nwin
 
4711
             << " ignored due to existence of input file (CC_IN_POS) "
 
4712
             << coarsecorrinput.ifpositions;
 
4713
        WARNING.print();
 
4714
        }
 
4715
      coarsecorrinput.Nwin = filelines(coarsecorrinput.ifpositions);
 
4716
      }
 
4717
    else if (coarsecorrinput.Nwin == def_cc_nwin+999)   // no inputfile, default
 
4718
      {
 
4719
      coarsecorrinput.Nwin = def_cc_nwin;
 
4720
      INFO.print("Default number of windows will be used for coarse coregistration.");
 
4721
      }
 
4722
    checkcoarsecorr(coarsecorrinput);
 
4723
    }
 
4724
 
 
4725
 
 
4726
// ====== Check input of step fine ======
 
4727
  if (generalinput.process[pr_i_fine])
 
4728
    {
 
4729
    if (fineinput.method == def_fc_method-999)  // see at defaults, no method card used
 
4730
      {
 
4731
      fineinput.method = def_fc_method;         // default method
 
4732
      INFO.print("Default method will be used for fine coregistration.");
 
4733
      }
 
4734
    if (specified(fineinput.ifpositions))         // filename specified
 
4735
      {
 
4736
      if (fineinput.Nwin != def_fc_nwin+999)    // something is specified
 
4737
        {
 
4738
        WARNING << "FC_NWIN: \t" << fineinput.Nwin
 
4739
             << " ignored due to existence of input file (FC_IN_POS) "
 
4740
             << fineinput.ifpositions;
 
4741
        WARNING.print();
 
4742
        }
 
4743
      fineinput.Nwin = filelines(fineinput.ifpositions);
 
4744
      }
 
4745
    else if (fineinput.Nwin == def_fc_nwin+999) // no inputfile, default
 
4746
      {
 
4747
      fineinput.Nwin = def_fc_nwin;
 
4748
      INFO.print("Default number of windows will be used for fine coregistration.");
 
4749
      }
 
4750
    checkfine(fineinput);
 
4751
    }
 
4752
 
 
4753
  // ====== Check input of TIMING step interferogram ====== [FvL]
 
4754
  if (generalinput.process[pr_i_timing])
 
4755
    {
 
4756
    checkreltiming(reltiminginput);
 
4757
    }
 
4758
 
 
4759
  // ====== Check input of DEMASSIST step interferogram ====== [FvL]
 
4760
  if (generalinput.process[pr_i_demassist])
 
4761
    {
 
4762
    checkdemassist(demassistinput);
 
4763
    }
 
4764
 
 
4765
  // ====== Check input step coregpm ======
 
4766
  if (generalinput.process[pr_i_coregpm])
 
4767
    {
 
4768
    checkcoregpm(coregpminput);
 
4769
    }
 
4770
 
 
4771
  // ====== Check + repair method selector resampling ======
 
4772
  if (generalinput.process[pr_s_resample])              // request for process resample
 
4773
    {
 
4774
    if (resampleinput.method == def_rs_method-999)      // see at defaults, no method card used
 
4775
      {
 
4776
      resampleinput.method = def_rs_method;             // default method
 
4777
      INFO.print("RS_METHOD: Using default.");
 
4778
      }
 
4779
    if (!priorrs_fileout)
 
4780
      INFO.print("RS_OUT_FILE: Using default.");
 
4781
    checkresample(resampleinput);
 
4782
    }
 
4783
 
 
4784
  // ====== Check + repair method selector flatearth correction ======
 
4785
  if (generalinput.process[pr_i_comprefpha])
 
4786
    {
 
4787
    if (comprefphainput.method == def_fe_method-999)     // see at defaults, no method card used
 
4788
      {
 
4789
      comprefphainput.method = def_fe_method;            // default method
 
4790
      INFO.print("FE_METHOD: Using default.");
 
4791
      }
 
4792
    if (comprefphainput.Npoints == def_fe_Npoints-999)   // default applies
 
4793
      {
 
4794
      comprefphainput.Npoints = def_fe_Npoints;          // default value
 
4795
      // INFO.print("FE_NPOINTS: Using default.");
 
4796
      }
 
4797
    // ______ if read from file, count number of points ______
 
4798
    if (specified(comprefphainput.ifpositions))         // filename specified
 
4799
      {
 
4800
      INFO.print("FE_IN_POS: Using file to read positions.");
 
4801
      comprefphainput.Npoints = filelines(comprefphainput.ifpositions);
 
4802
      }
 
4803
    if (comprefphainput.degree == def_fe_degree-999)     // default
 
4804
      {
 
4805
      comprefphainput.degree = def_fe_degree;            // default
 
4806
      INFO.print("FE_DEGREE: Using default.");
 
4807
      }
 
4808
    checkcomprefpha(comprefphainput);
 
4809
    }
 
4810
 
 
4811
  // ====== Check input of step interfero ======
 
4812
  if (generalinput.process[pr_i_interfero])
 
4813
    {
 
4814
    checkinterfero(interferoinput);
 
4815
    }
 
4816
 
 
4817
  // ====== Check input of SUBTRREFPHA step interferogram ======
 
4818
  if (generalinput.process[pr_i_subtrrefpha])
 
4819
    checksubtrrefpha(subtrrefphainput);
 
4820
 
 
4821
  // ====== Check input of COMPREFDEM step interferogram ======
 
4822
  if (generalinput.process[pr_i_comprefdem])
 
4823
    {
 
4824
    checkcomprefdem(comprefdeminput);
 
4825
    }
 
4826
 
 
4827
  // ====== Check input of SUBTRDEM step interferogram ======
 
4828
  if (generalinput.process[pr_i_subtrrefdem])
 
4829
    {
 
4830
    checksubtrrefdem(subtrrefdeminput);
 
4831
    }
 
4832
 
 
4833
  // ====== Check input of step coherence ======
 
4834
  if (generalinput.process[pr_i_coherence])
 
4835
    {
 
4836
    checkcoherence(coherenceinput);
 
4837
    }
 
4838
 
 
4839
  // ====== Check input of step phase filtering ======
 
4840
  if (generalinput.process[pr_i_filtphase])
 
4841
    {
 
4842
    if (!specified(filtphaseinput.fofiltphase))  // not specified, use default
 
4843
      {
 
4844
      if (filtphaseinput.method==fp_goldstein || filtphaseinput.method==fp_modgoldstein)
 
4845
        {
 
4846
        char dummy127[ONE27];
 
4847
        ostrstream omemfo(dummy127,ONE27);
 
4848
        omemfo << "cint." << filtphaseinput.alpha << "filtered" << ends;
 
4849
        strcpy(filtphaseinput.fofiltphase,dummy127);
 
4850
        if (filtphaseinput.kernel.size()==0)
 
4851
          {
 
4852
          INFO.print("PF_KERNEL: Using default kernel [1 2 3 2 1].");
 
4853
          filtphaseinput.kernel.resize(1,5);
 
4854
          filtphaseinput.kernel(0,0) = 1./9.;
 
4855
          filtphaseinput.kernel(0,1) = 2./9.;
 
4856
          filtphaseinput.kernel(0,2) = 3./9.;
 
4857
          filtphaseinput.kernel(0,3) = 2./9.;
 
4858
          filtphaseinput.kernel(0,4) = 1./9.;
 
4859
          }
 
4860
        }
 
4861
      else if (filtphaseinput.method==fp_spatialconv)
 
4862
        {
 
4863
        strcpy(filtphaseinput.fofiltphase,"cint.filtered");
 
4864
        // ______ Set default kernel ______
 
4865
        if (!specified(filtphaseinput.fikernel2d))      // no input file
 
4866
          {
 
4867
          if (filtphaseinput.kernel.size()==0)
 
4868
            {
 
4869
            INFO.print("PF_KERNEL: Using default kernel [1 1 1].");
 
4870
            filtphaseinput.kernel.resize(1,3);
 
4871
            filtphaseinput.kernel(0,0) = 1./3.;
 
4872
            filtphaseinput.kernel(0,1) = 1./3.;
 
4873
            filtphaseinput.kernel(0,2) = 1./3.;
 
4874
            }
 
4875
          }
 
4876
        }
 
4877
      else if (filtphaseinput.method==fp_spectral)
 
4878
        {
 
4879
        strcpy(filtphaseinput.fofiltphase,"cint.filtered");
 
4880
        }
 
4881
      else
 
4882
        {
 
4883
        PRINT_ERROR("Method filtphase not known")
 
4884
        throw(keyword_error);
 
4885
        }
 
4886
      }
 
4887
    checkfiltphase(filtphaseinput);
 
4888
    }
 
4889
 
 
4890
 
 
4891
  // ====== Check input of step unwrapping ======
 
4892
  if (generalinput.process[pr_i_unwrap])                 // request for process unwrapping
 
4893
    {
 
4894
    if (unwrapinput.method == def_uw_method-999)        // see at defaults, no method card used
 
4895
      {
 
4896
      unwrapinput.method = def_uw_method;               // default method
 
4897
      INFO.print("Default method will be used for unwrapping.");
 
4898
      }
 
4899
    checkunwrap(unwrapinput);
 
4900
    }
 
4901
 
 
4902
 
 
4903
  // ____ start added by HB ____
 
4904
  // ====== Check input of step estorbits ======
 
4905
  if (generalinput.process[pr_i_estorbits])
 
4906
    { 
 
4907
      // ______ check constraints______
 
4908
      bool setDefaultConstraints = false;
 
4909
      if(estorbitsinput.method==eo_gridsearch)
 
4910
        {
 
4911
          if (estorbitsinput.poldegree != 1)
 
4912
            {
 
4913
              estorbitsinput.poldegree = 1;
 
4914
              WARNING.print("Degree of orbit error polynomial changed to 1 for method GRIDSEARCH");
 
4915
            }
 
4916
          setDefaultConstraints = true;
 
4917
          INFO.print("Using constraints for method GRIDSEARCH: BPAR0 BPERP1");
 
4918
        }
 
4919
      else if (estorbitsinput.constrained==true && estorbitsinput.constraints.lines()==0) 
 
4920
        {
 
4921
          setDefaultConstraints = true;
 
4922
          INFO.print("Using default orbit constraints: BPAR0 BPERP1");
 
4923
        }
 
4924
      if (setDefaultConstraints)
 
4925
        {
 
4926
          estorbitsinput.constraints = matrix<int16>(2,2);
 
4927
          estorbitsinput.constraints(0,0) = 0;
 
4928
          estorbitsinput.constraints(0,1) = 0;
 
4929
          estorbitsinput.constraints(1,0) = 1;
 
4930
          estorbitsinput.constraints(1,1) = 1;
 
4931
        }
 
4932
 
 
4933
      // ______ check selection method of observation points ______
 
4934
      if (specified(estorbitsinput.ifpositions))         // filename specified
 
4935
      {
 
4936
        if (estorbitsinput.nobs != 0)      // something is specified
 
4937
          {
 
4938
            WARNING << "EO_NOBS: \t" << estorbitsinput.nobs
 
4939
                    << " ignored due to existence of input file (EO_IN_POS) "
 
4940
                    << estorbitsinput.ifpositions;
 
4941
            WARNING.print();
 
4942
          }
 
4943
        estorbitsinput.nobs = filelines(estorbitsinput.ifpositions);
 
4944
      }
 
4945
      else if (estorbitsinput.nobs == 0)   // no inputfile, default
 
4946
        {
 
4947
          estorbitsinput.nobs = def_eo_nobs;
 
4948
          INFO << "Default number of " << def_eo_nobs 
 
4949
               << " observations will be used for orbit error estimation.";
 
4950
          INFO.print();
 
4951
        }
 
4952
    }
 
4953
 
 
4954
 
 
4955
  // ====== Check input of step slant2height ======
 
4956
  if (generalinput.process[pr_i_slant2h])
 
4957
    {
 
4958
    if (slant2hinput.method == def_s2h_method-999)
 
4959
      {
 
4960
      slant2hinput.method = def_s2h_method;               // default method
 
4961
      INFO.print("Default method will be used for slant2h.");
 
4962
      }
 
4963
    if (slant2hinput.Nheights <= slant2hinput.degree1d)
 
4964
      {
 
4965
      WARNING << "S2H_NHEIGHTS: \t" << slant2hinput.Nheights 
 
4966
           << " is too large because S2H_DEGREE1D="
 
4967
           << slant2hinput.degree1d 
 
4968
           << "; set S2H_NHEIGHTS = " << slant2hinput.degree1d+1
 
4969
           << " (minimum)";
 
4970
      WARNING.print();
 
4971
      slant2hinput.Nheights = slant2hinput.degree1d + 1;
 
4972
      }
 
4973
    checkslant2h(slant2hinput);
 
4974
    }
 
4975
 
 
4976
 
 
4977
  // ====== Check input of step geocoding ======
 
4978
  if (generalinput.process[pr_i_geocoding])
 
4979
    {
 
4980
    checkgeocode(geocodeinput);
 
4981
    }
 
4982
 
 
4983
  // ====== Check input of dinsar step interferogram ======
 
4984
  if (generalinput.process[pr_i_dinsar])
 
4985
    {
 
4986
    if (!strcmp(dinsarinput.topomasterresfile,generalinput.m_resfile))
 
4987
      setunspecified(dinsarinput.topomasterresfile);    // used in check...
 
4988
    checkdinsar(dinsarinput);
 
4989
    if (!specified(dinsarinput.topomasterresfile))
 
4990
      strcpy(dinsarinput.topomasterresfile,generalinput.m_resfile);
 
4991
    }
 
4992
 
 
4993
  // ====== Check input of reserved EXTRA step interferogram ======
 
4994
  if (generalinput.process[pr_i_EXTRA2])
 
4995
    {
 
4996
    PRINT_ERROR("extra step2 interferogram not implemented.")
 
4997
    throw(keyword_error);
 
4998
    }
 
4999
 
 
5000
 
 
5001
 
 
5002
// ====== Copy input to logfile (via scratchfile, update in main) ======
 
5003
//   to avoid problems with not existing file it is always opened here
 
5004
  ofstream scratchreadinput("scratchreadinput", ios::out | ios::trunc);
 
5005
  bk_assert(scratchreadinput,"readinput: scratchreadinput",__FILE__,__LINE__);
 
5006
 
 
5007
  if (listinput)
 
5008
    {
 
5009
    // ______Start writing______
 
5010
    linecnt=0;
 
5011
    scratchreadinput << "\n----------------------------------------------------\n"
 
5012
                     << "      BEGIN: copy of input (non-interpretive).\n"
 
5013
                     << "-line---keyword----argument-------------comment-----\n";
 
5014
    optionsfile.seekg(0,ios::beg);
 
5015
    optionsfile.clear(); // clear eofbit
 
5016
    optionsfile.getline(eachline,4*ONE27,'\n');
 
5017
    while (optionsfile)
 
5018
      {
 
5019
      linecnt++;
 
5020
      scratchreadinput << setw(3) << linecnt << ": " << eachline << endl;
 
5021
      optionsfile.getline(eachline,4*ONE27,'\n');
 
5022
      }
 
5023
    scratchreadinput << "\n----------------------------------------------------\n"
 
5024
                     << "      END: copy of input.\n"
 
5025
                     << "----------------------------------------------------\n\n";
 
5026
    DEBUG.print("Finished writing to scratchreadinput.");
 
5027
    }
 
5028
 
 
5029
// ______Tidy up______
 
5030
  PROGRESS.print("Interpretation inputoptionsfile finished.");
 
5031
  scratchreadinput.close();
 
5032
  optionsfile.close();
 
5033
  } // END READINPUT
 
5034
 
 
5035
 
 
5036
 
 
5037
/****************************************************************
 
5038
 *    checkgeneral                                              *
 
5039
 *                                                              *
 
5040
 * Checks general cards.                                        *
 
5041
 * Repair process card                                          *
 
5042
 *                                                              *
 
5043
 *    Bert Kampes, 06-Sep-1999                                  *
 
5044
 ****************************************************************/
 
5045
void checkgeneral(
 
5046
        input_gen &generalinput,
 
5047
        const int16 onlyprocess)
 
5048
  {
 
5049
  TRACE_FUNCTION("checkgeneral (BK 06-Sep-1999)")
 
5050
  register int32 i;
 
5051
  int32 cs_processcard = 0;
 
5052
 
 
5053
// ______ Repair process control if ONLYPROCESS card was present ______
 
5054
  for (i=0; i<NUMPROCESSES; i++)
 
5055
    cs_processcard += generalinput.process[i];
 
5056
  if (onlyprocess != -1)                                     // initialized to -1;
 
5057
    {
 
5058
    generalinput.interactive=false;
 
5059
    INFO.print("ONLYPROCESS card present, batch processing.");
 
5060
    if (cs_processcard == 1)
 
5061
      WARNING.print("PROCESS card ignored due to presence ONLYPROCESS card.");
 
5062
    if (cs_processcard >  1)
 
5063
      WARNING.print("PROCESS cards ignored due to presence ONLYPROCESS card.");
 
5064
    for (i=0; i<NUMPROCESSES; i++)                      // do not process anything...
 
5065
      generalinput.process[i]=0;
 
5066
    generalinput.process[onlyprocess]=1;                  // exept this one.
 
5067
    }
 
5068
 
 
5069
  else                                                  // check process card presence
 
5070
    {
 
5071
    if (cs_processcard == 0)                            // no cards
 
5072
      {
 
5073
      PRINT_ERROR("code 303: No (ONLY)PROCESS card present, exiting.")
 
5074
      throw(keyword_error);
 
5075
      }
 
5076
    }
 
5077
 
 
5078
  INFO.print("\n\t*** General input cards ***");
 
5079
  INFO << "MEMORY: \tAvailable to Doris [MB]: \t"
 
5080
       << generalinput.memory/1e6;
 
5081
  INFO.print();
 
5082
 
 
5083
  INFO << "M_RESFILE: \tResultfile for master: \t\t"
 
5084
       << generalinput.m_resfile;
 
5085
  INFO.print();
 
5086
  INFO << "S_RESFILE: \tResultfile for slave: \t\t"
 
5087
       << generalinput.s_resfile;
 
5088
  INFO.print();
 
5089
  INFO << "I_RESFILE: \tResultfile for products: \t"
 
5090
       << generalinput.i_resfile;
 
5091
  INFO.print();
 
5092
  INFO << "LOGFILE: \tOut file for logging: \t\t"
 
5093
       << generalinput.logfile;
 
5094
  INFO.print();
 
5095
  INFO << "ORB_INTERP: \tmethod selector value:\t\t"
 
5096
       << generalinput.orb_interp;
 
5097
  INFO.print();
 
5098
  INFO << "ORB_PRM:   \torbit parameters selection value:\t\t"
 
5099
       << generalinput.orb_prm;
 
5100
  INFO.print();
 
5101
  INFO << "DUMPBASELINE: evaluation grid for baseline: \t"
 
5102
       << generalinput.dumpbaselineL << " lines x "
 
5103
       << generalinput.dumpbaselineP << " pixels: ";
 
5104
  INFO.print();
 
5105
  INFO << "HEIGHT: \taverage terrain height:\t\t"
 
5106
       << generalinput.terrain_height;
 
5107
  INFO.print();
 
5108
  INFO << "TIEPOINT: \tlat/lon/hei: "
 
5109
       << generalinput.tiepoint.x << " " 
 
5110
       << generalinput.tiepoint.y << " "
 
5111
       << generalinput.tiepoint.z;
 
5112
  INFO.print();
 
5113
 
 
5114
  if (!strcmp(generalinput.m_resfile,generalinput.s_resfile))
 
5115
    {
 
5116
    PRINT_ERROR("same name master and slave resultfile not allowed.")
 
5117
    throw(keyword_error);
 
5118
    }
 
5119
  if (!strcmp(generalinput.m_resfile,generalinput.i_resfile))
 
5120
    {
 
5121
    PRINT_ERROR("same name master and interferogram resultfile not allowed.");
 
5122
    throw(keyword_error);
 
5123
    }
 
5124
  if (!strcmp(generalinput.m_resfile,generalinput.logfile))
 
5125
    {
 
5126
    PRINT_ERROR("same name master resultfile and logfile not allowed.");
 
5127
    throw(keyword_error);
 
5128
    }
 
5129
  if (!strcmp(generalinput.i_resfile,generalinput.logfile))
 
5130
    {
 
5131
    PRINT_ERROR("same name interferogram resultfile and logfile not allowed.");
 
5132
    throw(keyword_error);
 
5133
    }
 
5134
  } // END checkgeneral
 
5135
 
 
5136
 
 
5137
/****************************************************************
 
5138
 *    checkreadfiles                                            *
 
5139
 *                                                              *
 
5140
 * Checks cards for step readfiles.                             *
 
5141
 *                                                              *
 
5142
 *    Bert Kampes, 06-Sep-1999                                  *
 
5143
 ****************************************************************/
 
5144
void checkreadfiles(
 
5145
        const input_readfiles &readfilesinput,
 
5146
        const int16 id)
 
5147
  {
 
5148
  TRACE_FUNCTION("checkreadfiles (BK 06-Sep-1999)")
 
5149
  switch (id)
 
5150
    {
 
5151
    case MASTERID:
 
5152
      INFO.print("\n\t*** Input for step M_READFILES (master) ***");
 
5153
      INFO << "M_IN_METHOD: \tmethod selected for master: \t\t"
 
5154
           << readfilesinput.sensor_id;
 
5155
      INFO.print();
 
5156
      INFO << "M_IN_VOL:    \tVolumefile of master: \t\t"
 
5157
           << readfilesinput.volfile;
 
5158
      INFO.print();
 
5159
      INFO << "M_IN_LEA:    \tLeaderfile of master: \t\t"
 
5160
           << readfilesinput.leaderfile;
 
5161
      INFO.print();
 
5162
      INFO << "M_IN_NULL:   \tNullfile of master:  \t\t"
 
5163
           << readfilesinput.nullfile;
 
5164
      INFO.print();
 
5165
      INFO << "M_IN_DAT:    \tDatfile of master:    \t\t"
 
5166
           << readfilesinput.datfile;
 
5167
      INFO.print();
 
5168
      if (readfilesinput.sensor_id == SLC_ERS)
 
5169
        {
 
5170
        if (!specified(readfilesinput.volfile))
 
5171
          {
 
5172
          PRINT_ERROR("M_IN_VOL not defined");
 
5173
          throw(keyword_error);
 
5174
          }
 
5175
        if (!specified(readfilesinput.leaderfile))
 
5176
          {
 
5177
          PRINT_ERROR("M_IN_LEA not defined");
 
5178
          throw(keyword_error);
 
5179
          }
 
5180
        if (!specified(readfilesinput.nullfile))
 
5181
          WARNING.print("M_IN_NULL not defined");
 
5182
        }
 
5183
      // ___ use datfile for asar input file ___
 
5184
      if (!specified(readfilesinput.datfile))
 
5185
        {
 
5186
        PRINT_ERROR("M_IN_DAT not defined");
 
5187
        throw(keyword_error);
 
5188
        }
 
5189
      if (readfilesinput.sensor_id == SLC_TSX)      // [MA] TSX 
 
5190
        {
 
5191
        if (!specified(readfilesinput.leaderfile))  // if changed, update also processor for leaderfile
 
5192
          {
 
5193
          PRINT_ERROR("M_IN_LEA not defined");
 
5194
          throw(keyword_error);
 
5195
          }
 
5196
        }
 
5197
      if (readfilesinput.sensor_id == SLC_RS2 || readfilesinput.sensor_id == SLC_RS2_QUAD )      // [MA] RS2 
 
5198
        {
 
5199
        if (!specified(readfilesinput.leaderfile))  // if changed, update also processor for leaderfile
 
5200
          {
 
5201
          PRINT_ERROR("M_IN_LEA not defined");
 
5202
          throw(keyword_error);
 
5203
          }
 
5204
        }
 
5205
      if (readfilesinput.sensor_id == SLC_CSK || readfilesinput.sensor_id == SLC_CSK_POL )      // [MA] CSK 
 
5206
        {
 
5207
        //if (!specified(readfilesinput.leaderfile))  // if changed, update also processor for leaderfile
 
5208
        if (!specified(readfilesinput.datfile))  // if changed, update also processor for leaderfile
 
5209
          {
 
5210
          //PRINT_ERROR("M_IN_LEA not defined");
 
5211
          PRINT_ERROR("M_IN_DAT not defined");
 
5212
          throw(keyword_error);
 
5213
          }
 
5214
        }
 
5215
      break;
 
5216
 
 
5217
    case SLAVEID:
 
5218
      INFO.print("\n\t*** Input for step S_READFILES (slave) ***");
 
5219
      INFO << "S_IN_METHOD: \tmethod selected for slave: \t\t"
 
5220
           << readfilesinput.sensor_id;
 
5221
      INFO.print();
 
5222
      INFO << "S_IN_VOL:    \tvolumefile of slave:  \t\t"
 
5223
           << readfilesinput.volfile;
 
5224
      INFO.print();
 
5225
      INFO << "S_IN_LEA:    \tleaderfile of slave:  \t\t"
 
5226
           << readfilesinput.leaderfile;
 
5227
      INFO.print();
 
5228
      INFO << "S_IN_NULL:   \tnullfile of slave:   \t\t"
 
5229
           << readfilesinput.nullfile;
 
5230
      INFO.print();
 
5231
      INFO << "S_IN_DAT:    \tdatfile of slave:     \t\t"
 
5232
           << readfilesinput.datfile;
 
5233
      INFO.print();
 
5234
      if (readfilesinput.sensor_id == SLC_ERS)
 
5235
        {
 
5236
        if (!specified(readfilesinput.volfile))
 
5237
          {
 
5238
          PRINT_ERROR("S_IN_VOL not defined");
 
5239
          throw(keyword_error);
 
5240
          }
 
5241
        if (!specified(readfilesinput.leaderfile))
 
5242
          {
 
5243
          PRINT_ERROR("S_IN_LEA not defined");
 
5244
          throw(keyword_error);
 
5245
          }
 
5246
        if (!specified(readfilesinput.nullfile))
 
5247
          WARNING.print("S_IN_NULL not defined");
 
5248
        }
 
5249
      // ___ use datfile for asar input file ___
 
5250
      if (!specified(readfilesinput.datfile))
 
5251
        {
 
5252
        PRINT_ERROR("S_IN_DAT not defined");
 
5253
        throw(keyword_error);
 
5254
        }
 
5255
      if (readfilesinput.sensor_id == SLC_TSX)      // [MA] TSX 
 
5256
        {
 
5257
        if (!specified(readfilesinput.leaderfile))  // if changed, update also processor.cc for the [leader]file
 
5258
          {
 
5259
          PRINT_ERROR("S_IN_LEA not defined");
 
5260
          throw(keyword_error);
 
5261
          }
 
5262
        }
 
5263
      if (readfilesinput.sensor_id == SLC_RS2 || readfilesinput.sensor_id == SLC_RS2_QUAD )      // [MA] RS2 
 
5264
        {
 
5265
        if (!specified(readfilesinput.leaderfile))  // if changed, update also processor for leaderfile
 
5266
          {
 
5267
          PRINT_ERROR("S_IN_LEA not defined");
 
5268
          throw(keyword_error);
 
5269
          }
 
5270
        }
 
5271
      if (readfilesinput.sensor_id == SLC_CSK || readfilesinput.sensor_id == SLC_CSK_POL )      // [MA] CSK 
 
5272
        {
 
5273
        //if (!specified(readfilesinput.leaderfile))  // if changed, update also processor for leaderfile
 
5274
        if (!specified(readfilesinput.datfile))  // if changed, update also processor for leaderfile
 
5275
          {
 
5276
          PRINT_ERROR("S_IN_DAT not defined");
 
5277
          throw(keyword_error);
 
5278
          }
 
5279
        }
 
5280
      break;
 
5281
 
 
5282
    default:
 
5283
      PRINT_ERROR("panic: impossible");
 
5284
      throw(keyword_error);
 
5285
    } // switch
 
5286
  if (readfilesinput.sensor_id == SLC_ERS)
 
5287
    {
 
5288
    if (!strcmp(readfilesinput.volfile,readfilesinput.leaderfile))
 
5289
      {
 
5290
      PRINT_ERROR("same file name volume and leader file not allowed.");
 
5291
      throw(keyword_error);
 
5292
      }
 
5293
    if (!strcmp(readfilesinput.volfile,readfilesinput.nullfile))
 
5294
      {
 
5295
      PRINT_ERROR("same file name volume and null file not allowed.");
 
5296
      throw(keyword_error);
 
5297
      }
 
5298
    if (!strcmp(readfilesinput.volfile,readfilesinput.datfile))
 
5299
      {
 
5300
      PRINT_ERROR("same file name volume and data file not allowed.");
 
5301
      throw(keyword_error);
 
5302
      }
 
5303
    if (!strcmp(readfilesinput.leaderfile,readfilesinput.nullfile))
 
5304
      {
 
5305
      PRINT_ERROR("same file name leader and null file not allowed.");
 
5306
      throw(keyword_error);
 
5307
      }
 
5308
    if (!strcmp(readfilesinput.leaderfile,readfilesinput.datfile))
 
5309
      {
 
5310
      PRINT_ERROR("same file name leader and data file not allowed.");
 
5311
      throw(keyword_error);
 
5312
      }
 
5313
    if (!strcmp(readfilesinput.nullfile,readfilesinput.datfile))
 
5314
      {
 
5315
      PRINT_ERROR("same file name null and data file not allowed.");
 
5316
      throw(keyword_error);
 
5317
      }
 
5318
    }
 
5319
  } // END checkreadfiles
 
5320
 
 
5321
 
 
5322
/****************************************************************
 
5323
 *    checkcrop                                                 *
 
5324
 *                                                              *
 
5325
 * Checks cards for step crop.                          *
 
5326
 *                                                              *
 
5327
 *    Bert Kampes, 06-Sep-1999                                  *
 
5328
 ****************************************************************/
 
5329
void checkcrop(
 
5330
        const input_crop &cropinput,
 
5331
        const int16 id)
 
5332
  {
 
5333
  TRACE_FUNCTION("checkcrop (BK 06-Sep-1999)")
 
5334
  switch (id)
 
5335
    {
 
5336
    case MASTERID:
 
5337
      INFO.print("\n\t*** Input for step M_CROP (master) ***");
 
5338
      INFO << "M_IDCROP: \tidentifier master write slc data to raster format: \t"
 
5339
           << cropinput.idcrop;
 
5340
      INFO.print();
 
5341
      INFO << "M_CROP_IN: \tslc data inputfile for master:   \t"
 
5342
           << cropinput.filein1;
 
5343
      INFO.print();
 
5344
      INFO << "M_CROP_OUT: \traw data outputfile for master: \t"
 
5345
           << cropinput.fileout1;
 
5346
      INFO.print();
 
5347
      INFO << "M_DBOW: \tProcessing master line "
 
5348
           << cropinput.dbow.linelo << " to "
 
5349
           << cropinput.dbow.linehi << ". pixel "
 
5350
           << cropinput.dbow.pixlo << " to "
 
5351
           << cropinput.dbow.pixhi << ".";
 
5352
      INFO.print();
 
5353
      if (cropinput.dbow_geo.pixhi != 0) 
 
5354
        {
 
5355
        INFO.print("M_DBOW_GEO: overrides M_DBOW! processing: ");
 
5356
        INFO << "center latitude " << cropinput.dbow_geo.linelo/1e6-360.0 <<
 
5357
                "; center longitude " << cropinput.dbow_geo.linehi/1e6-360.0 <<
 
5358
                "; height, width: " << cropinput.dbow_geo.pixlo << ", " << 
 
5359
                cropinput.dbow_geo.pixhi;
 
5360
        INFO.print();
 
5361
        }
 
5362
      break;
 
5363
 
 
5364
    case SLAVEID:
 
5365
      INFO.print("\n\t*** Input for step S_CROP (slave) ***");
 
5366
      INFO << "S_IDCROP: \tidentifier slave write slc data to raster format: \t"
 
5367
           << cropinput.idcrop;
 
5368
      INFO.print();
 
5369
      INFO << "S_CROP_IN: \tslc data inputfile for slave:   \t"
 
5370
           << cropinput.filein1;
 
5371
      INFO.print();
 
5372
      INFO << "S_CROP_OUT: \traw data outputfile for slave: \t"
 
5373
           << cropinput.fileout1;
 
5374
      INFO.print();
 
5375
      INFO << "S_DBOW: \tProcessing slave line "
 
5376
           << cropinput.dbow.linelo << " to "
 
5377
           << cropinput.dbow.linehi << ". pixel "
 
5378
           << cropinput.dbow.pixlo << " to "
 
5379
           << cropinput.dbow.pixhi << ".";
 
5380
      INFO.print();
 
5381
      if (cropinput.dbow_geo.pixhi != 0) 
 
5382
        {
 
5383
        INFO.print("S_DBOW_GEO: overrides S_DBOW! processing: ");
 
5384
        INFO << "center latitude " << cropinput.dbow_geo.linelo/1e6-360.0 <<
 
5385
                "; center longitude " << cropinput.dbow_geo.linehi/1e6-360.0 <<
 
5386
                "; height, width: " << cropinput.dbow_geo.pixlo << ", " << 
 
5387
                cropinput.dbow_geo.pixhi;
 
5388
        INFO.print();
 
5389
        }
 
5390
      break;
 
5391
 
 
5392
    default:
 
5393
      PRINT_ERROR("panic: impossible");
 
5394
      throw(keyword_error);
 
5395
    }
 
5396
  } // END checkcrop
 
5397
 
 
5398
 
 
5399
//____RaffaeleNutricato START MODIFICATION SECTION 11
 
5400
/****************************************************************
 
5401
 *    checkoversample                                           *
 
5402
 *                                                              *
 
5403
 * Checks cards for step oversample.                            *
 
5404
 *                                                              *
 
5405
 *    Raffaele Nutricato, 12-Jan-2004                           *
 
5406
 ****************************************************************/
 
5407
void checkoversample(
 
5408
        const input_oversample  &oversampleinput,
 
5409
        const int16 id)
 
5410
  {
 
5411
  TRACE_FUNCTION("checkoversample (Raffaele Nutricato 12-Jan-2004)")
 
5412
  switch (id)
 
5413
    {
 
5414
    case MASTERID:
 
5415
      INFO.print("\n\t*** Input for step M_OVS (master) ***");
 
5416
      INFO << "M_OVS_OUT: \t\tData output file for ovs master: "
 
5417
           << oversampleinput.fileoutovs; // Output file for the oversampled master
 
5418
      INFO.print(); 
 
5419
      INFO << "M_OVS_FACT_RNG: \tOversampling ratio in the master range direction: "   
 
5420
           << oversampleinput.OsrRange;  // Oversampling ratio in the range direction.
 
5421
      INFO.print(); 
 
5422
      INFO << "M_OVS_FACT_AZI: \tOversampling ratio in the master azimuth direction: "   
 
5423
           << oversampleinput.OsrAzimuth;  // Oversampling ratio in the azimuth direction.
 
5424
      INFO.print(); 
 
5425
      INFO << "M_OVS_KERNELSIZE: \tKernel length for the master oversampling: "   
 
5426
           << oversampleinput.FilterSize;  // Length of the interpolation kernel in range. 
 
5427
      INFO.print(); 
 
5428
      INFO << "M_OVS_OUT_FORMAT: \tOutput data format for the oversampled master: " ;  
 
5429
      if (oversampleinput.oformatflag==FORMATCR4)
 
5430
        INFO << "complex_real4";
 
5431
      if (oversampleinput.oformatflag==FORMATCI2)
 
5432
        INFO << "complex_short";
 
5433
      INFO.print();
 
5434
      break;
 
5435
 
 
5436
    case SLAVEID:
 
5437
      INFO.print("\n\t*** Input for step S_OVS (slave) ***");
 
5438
      INFO << "S_OVS_OUT: \t\tData output file for ovs slave: "
 
5439
           << oversampleinput.fileoutovs; // Output file for the oversampled slave
 
5440
      INFO.print();
 
5441
      INFO << "S_OVS_FACT_RNG: \tOversampling ratio in the slave range direction: "   
 
5442
           << oversampleinput.OsrRange;  // Oversampling ratio in the range direction.
 
5443
      INFO.print(); 
 
5444
      INFO << "S_OVS_FACT_AZI: \tOversampling ratio in the slave azimuth direction: "   
 
5445
           << oversampleinput.OsrAzimuth;  // Oversampling ratio in the azimuth direction.
 
5446
      INFO.print(); 
 
5447
      INFO << "S_OVS_KERNELSIZE: \tKernel length for the slave oversampling: "   
 
5448
           << oversampleinput.FilterSize;  // Length of the interpolation kernel in range. 
 
5449
      INFO.print(); 
 
5450
      INFO << "S_OVS_OUT_FORMAT: \tOutput data format for the oversampled slave: " ;  
 
5451
      if (oversampleinput.oformatflag==FORMATCR4)
 
5452
        INFO << "complex_real4";
 
5453
      if (oversampleinput.oformatflag==FORMATCI2)
 
5454
        INFO << "complex_short";
 
5455
      INFO.print();
 
5456
      break;
 
5457
 
 
5458
    default:
 
5459
      PRINT_ERROR("panic: impossible");
 
5460
      throw(keyword_error);
 
5461
    }
 
5462
  } // END checkoversample
 
5463
 
 
5464
//____RaffaeleNutricato END MODIFICATION SECTION 11
 
5465
 
 
5466
 
 
5467
/****************************************************************
 
5468
 *    checkporbits                                              *
 
5469
 *                                                              *
 
5470
 * Checks cards for step porbits.                               *
 
5471
 *                                                              *
 
5472
 *    Bert Kampes, 06-Sep-1999                                  *
 
5473
 ****************************************************************/
 
5474
void checkporbits(
 
5475
        const input_pr_orbits &porbitsinput,
 
5476
        const int16 id)
 
5477
  {
 
5478
  TRACE_FUNCTION("checkporbits (BK 06-Sep-1999)")
 
5479
  switch (id)
 
5480
    {
 
5481
    case MASTERID:
 
5482
      INFO.print("\n\t*** Input for step M_PORBITS (master) ***");
 
5483
      INFO << "M_ORBDIR: \tPrecise orbits master in: "
 
5484
           << porbitsinput.m_orbdir;
 
5485
      INFO.print();
 
5486
      if (!specified(porbitsinput.m_orbdir))
 
5487
        {
 
5488
        PRINT_ERROR("M_ORBDIR: no directory specified.");
 
5489
        throw(keyword_error);
 
5490
        }
 
5491
      break;
 
5492
 
 
5493
    case SLAVEID:
 
5494
      INFO.print("\n\t*** Input for step S_PORBITS (slave) ***");
 
5495
      INFO << "S_ORBDIR: \tPrecise orbits slave in: "
 
5496
           << porbitsinput.s_orbdir;
 
5497
      INFO.print();
 
5498
      if (!specified(porbitsinput.s_orbdir))
 
5499
        {
 
5500
        PRINT_ERROR("S_ORBDIR: no directory specified.");
 
5501
        throw(keyword_error);
 
5502
        }
 
5503
      break;
 
5504
 
 
5505
    default:
 
5506
      PRINT_ERROR("panic: impossible");
 
5507
      throw(keyword_error);
 
5508
    }
 
5509
  INFO << "ORB_INTERVAL: \ttime between ephemerides: \t"
 
5510
       << porbitsinput.timeinterval;
 
5511
  INFO.print();
 
5512
  INFO << "ORB_EXTRATIME: \ttime before first, after last line: \t"
 
5513
       << porbitsinput.timebefore;
 
5514
  INFO.print();
 
5515
  if (!porbitsinput.dumpmasterorbit<0)
 
5516
    INFO.print("dumping masterorbit to file.");
 
5517
  if (!porbitsinput.dumpslaveorbit<0)
 
5518
    INFO.print("dumping slaveorbit to file.");
 
5519
  } // END checkporbits
 
5520
 
 
5521
 
 
5522
/****************************************************************
 
5523
 *    checkslant2h                                              *
 
5524
 *                                                              *
 
5525
 * Checks cards for step slant2h.                               *
 
5526
 *                                                              *
 
5527
 *    Bert Kampes, 29-Sep-1999                                  *
 
5528
 ****************************************************************/
 
5529
void checkslant2h(
 
5530
        const input_slant2h &slant2hinput)
 
5531
  {
 
5532
  TRACE_FUNCTION("checkslant2h (BK 29-Sep-1999)")
 
5533
  INFO.print("\n\t*** Input for step SLANT2H ***");
 
5534
  switch (slant2hinput.method)
 
5535
    {
 
5536
    case s2h_schwabisch:
 
5537
      INFO.print("Method schwabisch is used for slant2height conversion.");
 
5538
 
 
5539
      INFO << "S2H_NPOINTS: \tNumber of points used in computation:   "
 
5540
           << slant2hinput.Npoints;
 
5541
      INFO.print();
 
5542
      INFO << "S2H_DEGREE1D: \tDegree of 1d polynomial at each point: "
 
5543
           << slant2hinput.degree1d;
 
5544
      INFO.print();
 
5545
      INFO << "S2H_DEGREE2D: \tDegree of 2d polynomial to compute     "
 
5546
           << "coefficients of 1D polynomial: "
 
5547
           << slant2hinput.degree2d;
 
5548
      INFO.print();
 
5549
      INFO << "S2H_NHEIGHTS: \t#heights evaluation ref. phase for 1d polynomial: "
 
5550
           << slant2hinput.Nheights;
 
5551
      INFO.print();
 
5552
      break;
 
5553
 
 
5554
    case s2h_ambiguity:
 
5555
      INFO.print("Method exact is used for slant2height conversion.");
 
5556
      INFO << "S2H_OUT_LAM: \tData output file for lambda: "
 
5557
           << slant2hinput.folam;
 
5558
      INFO.print();
 
5559
      INFO << "S2H_OUT_PHI: \tData output file for phi:    "
 
5560
           << slant2hinput.fophi;
 
5561
      INFO.print();
 
5562
      if (!strcmp(slant2hinput.folam,slant2hinput.fophi))
 
5563
        {
 
5564
        PRINT_ERROR("Same filename S2H_OUT_LAM and S2H_OUT_PHI not allowed.");
 
5565
        throw(keyword_error);
 
5566
        }
 
5567
      if (!strcmp(slant2hinput.fohei,slant2hinput.fophi))
 
5568
        {
 
5569
        PRINT_ERROR("Same filename S2H_OUT_HEI and S2H_OUT_PHI not allowed.");
 
5570
        throw(keyword_error);
 
5571
        }
 
5572
      if (!strcmp(slant2hinput.folam,slant2hinput.fohei))
 
5573
        {
 
5574
        PRINT_ERROR("Same filename S2H_OUT_LAM and S2H_OUT_HEI not allowed.");
 
5575
        throw(keyword_error);
 
5576
        }
 
5577
      break;
 
5578
 
 
5579
    case s2h_rodriguez:
 
5580
      DEBUG.print("do some checks here as well.");
 
5581
      break;
 
5582
 
 
5583
    default:
 
5584
      PRINT_ERROR("impossible, unknown method s2h");
 
5585
      throw(keyword_error);
 
5586
    }
 
5587
 
 
5588
    INFO << "S2H_OUT_HEI: Data output file for height:   "
 
5589
         << slant2hinput.fohei;
 
5590
    INFO.print();
 
5591
  } // END checkslant2h
 
5592
 
 
5593
 
 
5594
/****************************************************************
 
5595
 *    checkunwrap                                               *
 
5596
 *                                                              *
 
5597
 * Checks cards for step unwrap.                                *
 
5598
 *                                                              *
 
5599
 *    Bert Kampes, 29-Sep-1999                                  *
 
5600
 ****************************************************************/
 
5601
void checkunwrap(
 
5602
        const input_unwrap &unwrapinput)
 
5603
  {
 
5604
  TRACE_FUNCTION("checkunwrap (BK 29-Sep-1999)")
 
5605
  INFO.print("\n\t*** Input for step UNWRAP ***");
 
5606
  INFO << "UW_OUT_FILE: \tOutput data file for unwrapped interferogram: "
 
5607
       << unwrapinput.fouint;
 
5608
  INFO.print();
 
5609
  INFO << "UW_OUT_FORMAT: \tOutput data format for unwrapped interferogram: "
 
5610
       << unwrapinput.oformatflag;
 
5611
  INFO.print();
 
5612
  switch (unwrapinput.method)
 
5613
    {
 
5614
    case uw_method1:
 
5615
      INFO.print("Method 1 is used for unwrapping (treef_ramon unix calls).");
 
5616
      INFO << "UW_SEEDS: ";
 
5617
      if (isspace(unwrapinput.seedfile[0]))     // no file specified
 
5618
        INFO << "Delta seed in line/pixel direction: "
 
5619
             << unwrapinput.deltaLseed << " " << unwrapinput.deltaPseed;
 
5620
      else
 
5621
        INFO << " Input file with seeds for unwrapping: "
 
5622
             << unwrapinput.seedfile;
 
5623
      INFO.print();
 
5624
      INFO << "UW_OUT_REGIONS: \tOutput data file with region numbers: "
 
5625
           << unwrapinput.foregions;
 
5626
      INFO.print();
 
5627
      break;
 
5628
 
 
5629
    case uw_method2:
 
5630
      INFO.print("Method 2: SNAPHU is used for unwrapping.");
 
5631
      INFO.print("Please make sure snaphu is installed.  check results carefuly.");
 
5632
      INFO << "UW_SNAPHU_LOG: \tOutput log file of snaphu: "
 
5633
           << unwrapinput.snaphu_log;
 
5634
      INFO.print();
 
5635
      INFO << "UW_SNAPHU_INIT: \tinitialization method of snaphu: "
 
5636
           << unwrapinput.snaphu_init;
 
5637
      INFO.print();
 
5638
      INFO << "UW_SNAPHU_COH: \tinput coherence file for snaphu: "
 
5639
           << unwrapinput.snaphu_coh;
 
5640
      INFO.print();
 
5641
      INFO << "UW_SNAPHU_MODE: \tsnaphu mode: "
 
5642
           << unwrapinput.snaphu_mode;
 
5643
      INFO.print();
 
5644
      break;
 
5645
 
 
5646
    case uw_method3:
 
5647
      INFO.print("Method 3 is used for unwrapping (?).");
 
5648
      PRINT_ERROR("only for delft, standalone application.");
 
5649
      throw(keyword_error);
 
5650
      break;
 
5651
 
 
5652
    default:
 
5653
      PRINT_ERROR("probably forgot to update this, should not be possible.");
 
5654
      throw(keyword_error);
 
5655
    }
 
5656
  } // END checkunwrap
 
5657
 
 
5658
 
 
5659
/****************************************************************
 
5660
 *    checkgeocode                                              *
 
5661
 *                                                              *
 
5662
 * Checks cards for step geocode.                               *
 
5663
 *                                                              *
 
5664
 *    Bert Kampes, 29-Sep-1999                                  *
 
5665
 ****************************************************************/
 
5666
void checkgeocode(
 
5667
        const input_geocode &geocodeinput)
 
5668
  {
 
5669
  TRACE_FUNCTION("checkgeocode (BK 29-Sep-1999)")
 
5670
  INFO.print("\n\t*** Input for step GEOCODE ***");
 
5671
  INFO << "GEO_OUT_PHI: \tOutput file for latitude: \t"
 
5672
       << geocodeinput.fophi;
 
5673
  INFO.print();
 
5674
  INFO << "GEO_OUT_PHI: \tOutput file for longitude: \t"
 
5675
       << geocodeinput.folam;
 
5676
  INFO.print();
 
5677
  if (!strcmp(geocodeinput.fophi,geocodeinput.folam))
 
5678
    {
 
5679
    ERROR << "Same file name GEO_OUT_PHI and GEO_OUT_LAM not allowed.";
 
5680
    PRINT_ERROR(ERROR.get_str())
 
5681
    throw(keyword_error);
 
5682
    }
 
5683
  } // END checkgeocode
 
5684
 
 
5685
 
 
5686
 
 
5687
/****************************************************************
 
5688
 *    checkcoarsecorr                                           *
 
5689
 *                                                              *
 
5690
 * Checks cards for step coarsecorr.                            *
 
5691
 *                                                              *
 
5692
 *    Bert Kampes, 29-Sep-1999                                  *
 
5693
 ****************************************************************/
 
5694
void checkcoarsecorr(
 
5695
        const input_coarsecorr &coarsecorrinput)
 
5696
  {
 
5697
  TRACE_FUNCTION("checkcoarsecorr (BK 29-Sep-1999)")
 
5698
  INFO.print("\n\t*** Input for step COARSE_CORR ***");
 
5699
  switch (coarsecorrinput.method)
 
5700
    {
 
5701
    case cc_magfft:
 
5702
      INFO.print("CC_METHOD: \tMAGFFT is used for coarse correlation."); break;
 
5703
    case cc_magspace:
 
5704
      INFO.print("CC_METHOD: \tMAGSPACE is used for coarse correlation."); break;
 
5705
    default:
 
5706
      PRINT_ERROR("panic.");
 
5707
      throw(keyword_error);
 
5708
    }
 
5709
  if (specified(coarsecorrinput.ifpositions))
 
5710
    {
 
5711
    INFO << "CC_IN_POS: \tFile: " <<  coarsecorrinput.ifpositions 
 
5712
         << " containing " << coarsecorrinput.Nwin
 
5713
         << " positions is used.";
 
5714
    INFO.print();
 
5715
    }
 
5716
  else                                          // no input file
 
5717
    {
 
5718
    INFO << "CC_NWIN: \tDistributing "
 
5719
         <<  coarsecorrinput.Nwin 
 
5720
         << " windows for coarse coregistration based on correlation.";
 
5721
    INFO.print();
 
5722
    }
 
5723
  } // END checkcoarsecorr
 
5724
 
 
5725
 
 
5726
/****************************************************************
 
5727
 *    checkfine                                                 *
 
5728
 *                                                              *
 
5729
 * Checks cards for step fine.                                  *
 
5730
 *                                                              *
 
5731
 *    Bert Kampes, 29-Sep-1999                                  *
 
5732
 ****************************************************************/
 
5733
void checkfine(
 
5734
        const input_fine &fineinput)
 
5735
  {
 
5736
  TRACE_FUNCTION("checkfine (BK 29-Sep-1999)")
 
5737
  INFO.print("\n\t*** Input for step FINE ***");
 
5738
  switch (fineinput.method)
 
5739
    {
 
5740
//    case fc_cmplxfft:
 
5741
//      INFO.print("FC_METHOD: \tCMPLXFFT is used for fine correlation.");
 
5742
//      break;
 
5743
//    case fc_cmplxspace:
 
5744
//      INFO.print("FC_METHOD: \tCMPLXSPACE is used for fine correlation.");
 
5745
//      break;
 
5746
    case fc_magfft:
 
5747
      INFO.print("FC_METHOD: \tMAGFFT is used for fine correlation.");
 
5748
      break;
 
5749
    case fc_magspace:
 
5750
      INFO.print("FC_METHOD: \tMAGSPACE is used for fine correlation.");
 
5751
      break;
 
5752
    case fc_oversample:
 
5753
      INFO.print("FC_METHOD: \tOVERSAMPLE is used for fine correlation.");
 
5754
      break;
 
5755
    default:
 
5756
      PRINT_ERROR("panic.");
 
5757
      throw(keyword_error);
 
5758
    }
 
5759
 
 
5760
  if (specified(fineinput.ifpositions))
 
5761
    {
 
5762
    INFO << "FC_IN_POS: File: "
 
5763
         <<  fineinput.ifpositions 
 
5764
         << " containing "
 
5765
         << fineinput.Nwin << " positions is used.";
 
5766
    INFO.print();
 
5767
    }
 
5768
  else                                          // no input file
 
5769
    {
 
5770
    INFO << "FC_NWIN: \tDistributing "
 
5771
         <<  fineinput.Nwin 
 
5772
         << " windows for fine coregistration.";
 
5773
    INFO.print();
 
5774
    }
 
5775
  if (fineinput.plotoffsets)
 
5776
    {
 
5777
    INFO << "FC_PLOT " << fineinput.plotthreshold 
 
5778
         << ": Plotting estimated offsets with correlation > "
 
5779
         << fineinput.plotthreshold;
 
5780
    INFO.print();
 
5781
    }
 
5782
  else
 
5783
    {
 
5784
    WARNING.print("It is highly recommended to use FC_PLOT to plot the computed FINE offset vectors.");
 
5785
    }
 
5786
  if (fineinput.plotmagbg)
 
5787
    INFO.print("FC_PLOT: magnitude will be in background of plot.");
 
5788
 
 
5789
  INFO << "FC_WINSIZE for correlation: (l,p) = ("
 
5790
       <<  fineinput.MasksizeL << ", "
 
5791
       <<  fineinput.MasksizeP << ").";
 
5792
  INFO.print();
 
5793
  INFO.print("Max. estimable offset is half the window size");
 
5794
  INFO.print("If the offset varies a lot over the image, use larger winsize");
 
5795
  INFO << "FC_WINSIZE for oversampling (2*Acc): (l,p) = ("
 
5796
       <<  2*fineinput.AccL << ", "
 
5797
       <<  2*fineinput.AccP << ").";
 
5798
  INFO.print();
 
5799
  INFO << "FC_OSFACTOR: "
 
5800
       <<  fineinput.osfactor
 
5801
       <<  ". Oversampling factor for fine coregistration.";
 
5802
  INFO.print();
 
5803
  if (!ispower2(fineinput.osfactor))
 
5804
    {
 
5805
    ERROR << " no power of 2.";
 
5806
    PRINT_ERROR(ERROR.get_str())
 
5807
    throw(keyword_error);
 
5808
    }
 
5809
  } // END checkfine
 
5810
 
 
5811
 
 
5812
/****************************************************************
 
5813
 *    checksimamp                                               *
 
5814
 *                                                              *
 
5815
 * Checks cards for step simamp.                                *
 
5816
 *                                                              *
 
5817
 *    Mahmut Arikan, 30-Oct-2008                                *
 
5818
 ****************************************************************/
 
5819
void checksimamp(
 
5820
        const input_simamp &simampinput)
 
5821
  {
 
5822
  TRACE_FUNCTION("checksimamp (MA 30-oct-2008)")
 
5823
  INFO.print("\n\t*** Input for step SIMAMP ***");
 
5824
  INFO << "SAM_IN_DEM:    \t" << simampinput.firefdem;
 
5825
  INFO.print();
 
5826
  if (specified(simampinput.fothetalp))                              // MA SPT
 
5827
    {
 
5828
    INFO << "SAM_OUT_THETA_LP: \t" << simampinput.fothetalp
 
5829
       << "; output requested of incidence angle THETA [rad] in radar coordinates.";
 
5830
    INFO.print();
 
5831
    }
 
5832
  if (specified(simampinput.fodemlp))                              // MA SPT
 
5833
    {
 
5834
    INFO << "SAM_OUT_DEM_LP: \t" << simampinput.fodemlp
 
5835
       << "; output requested of DEM [m] in radar coordinates.";
 
5836
    INFO.print();
 
5837
    }
 
5838
  if (specified(simampinput.fodem))
 
5839
    {
 
5840
    INFO << "SAM_OUT_DEM:   \t" << simampinput.fodem
 
5841
       << "; output requested of input DEM.";
 
5842
    INFO.print();
 
5843
    if (!strcmp(simampinput.fosimamp,simampinput.fodem))
 
5844
      {
 
5845
      PRINT_ERROR("OUT_DEM, OUT_FILE: Same output file name.");
 
5846
      throw(keyword_error);
 
5847
      }
 
5848
    }
 
5849
  if (specified(simampinput.fosimamp))
 
5850
    {
 
5851
    INFO << "SAM_OUT_FILE:   \t" << simampinput.fosimamp
 
5852
         << "; output requested of simulated amplitude.";
 
5853
    INFO.print();
 
5854
    if (!strcmp(simampinput.fosimamp,simampinput.fodem))
 
5855
      {
 
5856
      PRINT_ERROR("OUT_DEM, OUT_FILE: Same output file name.");
 
5857
      throw(keyword_error);
 
5858
      }
 
5859
    }
 
5860
  INFO << "SAM_IN_SIZE:   \t" << simampinput.demrows
 
5861
       << " " << simampinput.demcols
 
5862
       << "; number of rows (latitude), columns (lon) in DEM.";
 
5863
  INFO.print();
 
5864
  INFO << "SAM_IN_UL:     \t" 
 
5865
       << rad2deg(simampinput.demlatleftupper) << " "
 
5866
       << rad2deg(simampinput.demlonleftupper)
 
5867
       << "; coordinates of upper left corner (first row/col).";
 
5868
  INFO.print();
 
5869
  INFO << "SAM_IN_DELTA:  \t"
 
5870
       << rad2deg(simampinput.demdeltalat) << " "
 
5871
       << rad2deg(simampinput.demdeltalon);
 
5872
  INFO.print();
 
5873
  INFO << "SAM_IN_NODATA:  \t" << simampinput.demnodata
 
5874
       << "; this number in DEM will be set to 0 reference phase.";
 
5875
  INFO.print();
 
5876
 
 
5877
  INFO << "SAM_IN_FORMAT: \tinput format DEM: \t";
 
5878
  switch (simampinput.iformatflag)
 
5879
    {
 
5880
    case FORMATR4:
 
5881
      INFO << "real4.";
 
5882
      break;
 
5883
    case FORMATR8:
 
5884
      INFO << "real8.";
 
5885
      break;
 
5886
    case FORMATI2:
 
5887
      INFO << "signed short.";
 
5888
      break;
 
5889
    case FORMATI2_BIGENDIAN:
 
5890
      INFO << "signed short big endian.";
 
5891
      break;
 
5892
    default:
 
5893
      PRINT_ERROR("totally impossible, checked input.");
 
5894
      throw(keyword_error);
 
5895
    }
 
5896
  INFO.print();
 
5897
 
 
5898
 
 
5899
 
 
5900
// ______ Check some things ______
 
5901
  if (!existed(simampinput.firefdem))
 
5902
    {
 
5903
    ERROR << "SAM_IN_DEM:   \t" << simampinput.firefdem
 
5904
         << " can not be opened.";
 
5905
    PRINT_ERROR(ERROR.get_str())
 
5906
    throw(keyword_error);
 
5907
    }
 
5908
  if (rad2deg(simampinput.demdeltalat)<.0002) // [MA] 1 arc secs = 1/3600=0.00027 : allow finer resolutions
 
5909
    {
 
5910
    WARNING << "SAM_IN_DELTA: \t" << rad2deg(simampinput.demdeltalat)
 
5911
         << " [deg] seems very small (input in decimal degrees).";
 
5912
    WARNING.print();
 
5913
    }
 
5914
  if (simampinput.demrows<1 || simampinput.demrows>100000)
 
5915
    {
 
5916
    WARNING << "SAM_DEM_SIZE: numrows: \t" << simampinput.demrows
 
5917
         << " seems to be wrong.";
 
5918
    WARNING.print();
 
5919
    }
 
5920
  if (simampinput.demcols<1 || simampinput.demcols>100000)
 
5921
    {
 
5922
    WARNING << "SAM_DEM_SIZE: numcols: \t" << simampinput.demcols
 
5923
         << " seems to be wrong.";
 
5924
    WARNING.print();
 
5925
    }
 
5926
  if (rad2deg(simampinput.demdeltalon)<.0002)  
 
5927
    {
 
5928
    WARNING << "SAM_IN_DELTA: \t" << simampinput.demdeltalon
 
5929
         << " seems very small (it should be in decimal degrees).";
 
5930
    WARNING.print();
 
5931
    }
 
5932
  if (rad2deg(simampinput.demlatleftupper) < -90. ||
 
5933
      rad2deg(simampinput.demlatleftupper) >  90.   )
 
5934
    {
 
5935
    ERROR << "SAM_IN_LU:    \t" << rad2deg(simampinput.demlatleftupper)
 
5936
         << " out of range (-90:90).";
 
5937
    PRINT_ERROR(ERROR.get_str())
 
5938
    throw(keyword_error);
 
5939
    }
 
5940
  if (rad2deg(simampinput.demlonleftupper) < -180. ||
 
5941
      rad2deg(simampinput.demlonleftupper) >  180.   )
 
5942
    {
 
5943
    WARNING << "SAM_IN_LU:    \t" << rad2deg(simampinput.demlonleftupper)
 
5944
         << " out of range (-180:180).";
 
5945
    WARNING.print();
 
5946
    }
 
5947
  } // END simamp  [MA]
 
5948
 
 
5949
 
 
5950
 
 
5951
/****************************************************************
 
5952
 *    checkmtiming                                              *
 
5953
 *                                                              *
 
5954
 * Checks cards for step simamp corr.                           *
 
5955
 *                                                              *
 
5956
 *    Mahmut Arikan, 11-Nov-2008                                *
 
5957
 ****************************************************************/
 
5958
void checkmtiming(
 
5959
        const input_mtiming &mtiminginput)
 
5960
  {
 
5961
  TRACE_FUNCTION("checkmtiming (MA, BO 11-Nov-2008)")
 
5962
  INFO.print("\n\t*** Input for step MASTER TIMING ***");
 
5963
  switch (mtiminginput.method)
 
5964
    {
 
5965
    case cc_magfft:
 
5966
      INFO.print("MTE_METHOD: \tMAGFFT is used for MASTER TIMING ERROR estimation."); break;
 
5967
    case cc_magspace:
 
5968
      INFO.print("MTE_METHOD: \tMAGSPACE is used for MASTER TIMING ERROR estimation."); break;
 
5969
    default:
 
5970
      PRINT_ERROR("panic.");
 
5971
      throw(keyword_error);
 
5972
    }
 
5973
  if (specified(mtiminginput.ifpositions))
 
5974
    {
 
5975
    INFO << "MTE_IN_POS: \tFile: " <<  mtiminginput.ifpositions 
 
5976
         << " containing " << mtiminginput.Nwin
 
5977
         << " positions is used.";
 
5978
    INFO.print();
 
5979
    }
 
5980
  else                                          // no input file
 
5981
    {
 
5982
    INFO << "MTE_NWIN: \tDistributing "
 
5983
         <<  mtiminginput.Nwin 
 
5984
         << " windows for master timing error estimation (correlation).";
 
5985
    INFO.print();
 
5986
    }
 
5987
  } // END checkmtiming
 
5988
 
 
5989
 
 
5990
// ____end added by MA ____
 
5991
 
 
5992
 
 
5993
// ____start added by FvL ____
 
5994
 
 
5995
/****************************************************************
 
5996
 *    checkreltiming                                            *
 
5997
 *                                                              *
 
5998
 * Checks cards for step timing                                 *
 
5999
 *                                                              *
 
6000
 *    Freek van Leijen, 22-Aug-2007                             *
 
6001
 ****************************************************************/
 
6002
void checkreltiming(
 
6003
        const input_reltiming &timinginput)
 
6004
  {
 
6005
  TRACE_FUNCTION("checkreltiming (FvL 22-aug-2007)")
 
6006
  INFO.print("\n\t*** Input for step REL_TIMING ***");
 
6007
  INFO << "RTE_THRESHOLD: \tThreshold correlation for model: \t"
 
6008
       <<  timinginput.threshold;
 
6009
  INFO.print();
 
6010
  INFO << "RTE_MAXITER: \tNumber of points to remove (max): \t"
 
6011
       <<  timinginput.maxiter;
 
6012
  INFO.print();
 
6013
  INFO << "RTE_K_ALPHA: \tCritical value for outlier test: \t"
 
6014
       <<  timinginput.k_alpha;
 
6015
  INFO.print();
 
6016
  } // END checkreltiming
 
6017
 
 
6018
 
 
6019
/****************************************************************
 
6020
 *    checkdemassist                                            *
 
6021
 *                                                              *
 
6022
 * Checks cards for step demassist.                             *
 
6023
 *                                                              *
 
6024
 *    Freek van Leijen, 22-Aug-2007                             *
 
6025
 ****************************************************************/
 
6026
void checkdemassist(
 
6027
        const input_demassist &demassistinput)
 
6028
  {
 
6029
  TRACE_FUNCTION("checkdemassist (FvL 22-aug-2007)")
 
6030
  INFO.print("\n\t*** Input for step DEMASSIST ***");
 
6031
  INFO << "DAC_IN_DEM:    \t" << demassistinput.firefdem;
 
6032
  INFO.print();
 
6033
  if (specified(demassistinput.forefdemhei))
 
6034
    {
 
6035
    INFO << "DAC_OUT_DEM_LP: \t" << demassistinput.forefdemhei
 
6036
       << "; output requested of DEM [m] in radar coordinates.";
 
6037
    INFO.print();
 
6038
    }
 
6039
  if (specified(demassistinput.fodem))
 
6040
    {
 
6041
    INFO << "DAC_OUT_DEM:   \t" << demassistinput.fodem
 
6042
       << "; output requested of input DEM.";
 
6043
    INFO.print();
 
6044
    if (!strcmp(demassistinput.fodemi,demassistinput.fodem))
 
6045
      {
 
6046
      PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
 
6047
      throw(keyword_error);
 
6048
      }
 
6049
    }
 
6050
  if (specified(demassistinput.fodemi))
 
6051
    {
 
6052
    INFO << "DAC_OUT_DEMI:   \t" << demassistinput.fodemi
 
6053
         << "; output requested of interpolated DEM.";
 
6054
    INFO.print();
 
6055
    if (!strcmp(demassistinput.fodemi,demassistinput.fodem))
 
6056
      {
 
6057
      PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
 
6058
      throw(keyword_error);
 
6059
      }
 
6060
    }
 
6061
  INFO << "DAC_IN_SIZE:   \t" << demassistinput.demrows
 
6062
       << " " << demassistinput.demcols
 
6063
       << "; number of rows (latitude), columns (lon) in DEM.";
 
6064
  INFO.print();
 
6065
  INFO << "DAC_IN_UL:     \t" 
 
6066
       << rad2deg(demassistinput.demlatleftupper) << " "
 
6067
       << rad2deg(demassistinput.demlonleftupper)
 
6068
       << "; coordinates of upper left corner (first row/col).";
 
6069
  INFO.print();
 
6070
  INFO << "DAC_IN_DELTA:  \t"
 
6071
       << rad2deg(demassistinput.demdeltalat) << " "
 
6072
       << rad2deg(demassistinput.demdeltalon);
 
6073
  INFO.print();
 
6074
  INFO << "DAC_IN_NODATA:  \t" << demassistinput.demnodata
 
6075
       << "; this number in DEM will be set to 0 reference phase.";
 
6076
  INFO.print();
 
6077
 
 
6078
  INFO << "DAC_IN_FORMAT: \tinput format DEM: \t";
 
6079
  switch (demassistinput.iformatflag)
 
6080
    {
 
6081
    case FORMATR4:
 
6082
      INFO << "real4.";
 
6083
      break;
 
6084
    case FORMATR8:
 
6085
      INFO << "real8.";
 
6086
      break;
 
6087
    case FORMATI2:
 
6088
      INFO << "signed short.";
 
6089
      break;
 
6090
    case FORMATI2_BIGENDIAN:
 
6091
      INFO << "signed short big endian.";
 
6092
      break;
 
6093
    default:
 
6094
      PRINT_ERROR("totally impossible, checked input.");
 
6095
      throw(keyword_error);
 
6096
    }
 
6097
  INFO.print();
 
6098
 
 
6099
 
 
6100
 
 
6101
// ______ Check some things ______
 
6102
  if (!existed(demassistinput.firefdem))
 
6103
    {
 
6104
    ERROR << "DAC_IN_DEM:   \t" << demassistinput.firefdem
 
6105
         << " can not be opened.";
 
6106
    PRINT_ERROR(ERROR.get_str())
 
6107
    throw(keyword_error);
 
6108
    }
 
6109
  if (rad2deg(demassistinput.demdeltalat)<.0002) //[MA] 1 arc secs = 1/3600=0.00027 : allow finer resolutions
 
6110
    {
 
6111
    WARNING << "DAC_IN_DELTA: \t" << rad2deg(demassistinput.demdeltalat)
 
6112
         << " [deg] seems very small (input in decimal degrees).";
 
6113
    WARNING.print();
 
6114
    }
 
6115
  if (demassistinput.demrows<1 || demassistinput.demrows>100000)
 
6116
    {
 
6117
    WARNING << "DAC_DEM_SIZE: numrows: \t" << demassistinput.demrows
 
6118
         << " seems to be wrong.";
 
6119
    WARNING.print();
 
6120
    }
 
6121
  if (demassistinput.demcols<1 || demassistinput.demcols>100000)
 
6122
    {
 
6123
    WARNING << "DAC_DEM_SIZE: numcols: \t" << demassistinput.demcols
 
6124
         << " seems to be wrong.";
 
6125
    WARNING.print();
 
6126
    }
 
6127
  if (rad2deg(demassistinput.demdeltalon)<.0002)
 
6128
    {
 
6129
    WARNING << "DAC_IN_DELTA: \t" << demassistinput.demdeltalon
 
6130
         << " seems very small (it should be in decimal degrees).";
 
6131
    WARNING.print();
 
6132
    }
 
6133
  if (rad2deg(demassistinput.demlatleftupper) < -90. ||
 
6134
      rad2deg(demassistinput.demlatleftupper) >  90.   )
 
6135
    {
 
6136
    ERROR << "DAC_IN_LU:    \t" << rad2deg(demassistinput.demlatleftupper)
 
6137
         << " out of range (-90:90).";
 
6138
    PRINT_ERROR(ERROR.get_str())
 
6139
    throw(keyword_error);
 
6140
    }
 
6141
  if (rad2deg(demassistinput.demlonleftupper) < -180. ||
 
6142
      rad2deg(demassistinput.demlonleftupper) >  180.   )
 
6143
    {
 
6144
    WARNING << "DAC_IN_LU:    \t" << rad2deg(demassistinput.demlonleftupper)
 
6145
         << " out of range (-180:180).";
 
6146
    WARNING.print();
 
6147
    }
 
6148
  } // END demassist
 
6149
 
 
6150
// ____end added by FvL ____
 
6151
 
 
6152
 
 
6153
/****************************************************************
 
6154
 *    checkcoregpm                                              *
 
6155
 *                                                              *
 
6156
 * Checks cards for step coregpm.                               *
 
6157
 *                                                              *
 
6158
 *    Bert Kampes, 29-Sep-1999                                  *
 
6159
 ****************************************************************/
 
6160
void checkcoregpm(
 
6161
        const input_coregpm &coregpminput)
 
6162
  {
 
6163
  TRACE_FUNCTION("checkcoregpm (BK 29-Sep-1999)")
 
6164
  INFO.print("\n\t*** Input for step COREGPM ***");
 
6165
  INFO << "CPM_THRESHOLD: \tThreshold correlation for model: \t"
 
6166
       <<  coregpminput.threshold;
 
6167
  INFO.print();
 
6168
  INFO << "CPM_DEGREE: \tPolynomial for coregistration: \t"
 
6169
       <<  coregpminput.degree;
 
6170
  INFO.print();
 
6171
  INFO << "CPM_WEIGHT: \tData weighting option: \t"
 
6172
       <<  coregpminput.weightflag
 
6173
       << " (0 none, 1 linear, 2 quadratic, 3 bamler paper) is used.";
 
6174
  INFO.print();
 
6175
  INFO << "CPM_MAXITER: \tNumber of points to remove (max): \t"
 
6176
       <<  coregpminput.maxiter;
 
6177
  INFO.print();
 
6178
  INFO << "CPM_K_ALPHA: \tCritical value for outlier test: \t"
 
6179
       <<  coregpminput.k_alpha;
 
6180
  INFO.print();
 
6181
  if (coregpminput.dumpmodel)
 
6182
    INFO.print("CPM_DUMP: dumping model to files (see INFO).");
 
6183
  if (coregpminput.plot)
 
6184
    INFO.print("CPM_PLOT: error vectors etc. will be plotted.");
 
6185
  else
 
6186
    WARNING.print("It is higly recommended to use CPM_PLOT to review the estimated model.");
 
6187
  if (coregpminput.plotmagbg)
 
6188
    INFO.print("CPM_PLOT: magnitude will be in background.");
 
6189
  } // END checkcoregpm
 
6190
 
 
6191
 
 
6192
/****************************************************************
 
6193
 *    checkcomprefpha                                           *
 
6194
 *                                                              *
 
6195
 * Checks cards for step comprefpha.                            *
 
6196
 *                                                              *
 
6197
 *    Bert Kampes, 29-Sep-1999                                  *
 
6198
 ****************************************************************/
 
6199
void checkcomprefpha(
 
6200
        const input_comprefpha &comprefphainput)
 
6201
  {
 
6202
  TRACE_FUNCTION("checkcomprefpha (BK 29-Sep-1999)")
 
6203
  INFO.print("\n\t*** Input for step COMPREFPHA ***");
 
6204
  switch (comprefphainput.method)
 
6205
    {
 
6206
    case fe_porbits:
 
6207
      INFO.print("FE_METHOD: method for flatearth correction: PORBITS");
 
6208
      // ______ Check points from file or random distributed ______
 
6209
      if (specified(comprefphainput.ifpositions))
 
6210
        {
 
6211
        INFO << "FE_IN_POS: file: "
 
6212
             <<  comprefphainput.ifpositions 
 
6213
             << " containing "
 
6214
             << comprefphainput.Npoints << " positions used for ref. phase estimation.";
 
6215
        INFO.print();
 
6216
        }
 
6217
      else                                              // no input file
 
6218
        {
 
6219
        INFO << "FE_NPOINTS: Using " << comprefphainput.Npoints
 
6220
             << " (random like) distributed points for estimation of refpha polynomial.";
 
6221
        INFO.print();
 
6222
        }
 
6223
      if (comprefphainput.Npoints > 5000)
 
6224
        WARNING.print("FE_NPOINTS: Too many points requested?");
 
6225
      INFO << "FE_DEGREE: Using " << comprefphainput.degree
 
6226
           << " order polynomial for flat Earth correction.";
 
6227
      INFO.print();
 
6228
      if (comprefphainput.degree > 10)
 
6229
        WARNING.print("FE_DEGREE: degree > 10?");
 
6230
      break;
 
6231
    case fe_method2:
 
6232
      INFO.print("FE_METHOD: method for flatearth correction: method2 :NOT IMPLEMENTED");
 
6233
      break;
 
6234
    default:
 
6235
      PRINT_ERROR("impossible, method name is checked while reading cards.");
 
6236
      throw(keyword_error);
 
6237
    }
 
6238
  } // END checkcomprefpha
 
6239
 
 
6240
 
 
6241
/****************************************************************
 
6242
 *    checksubtrrefpha                                          *
 
6243
 *                                                              *
 
6244
 * Checks cards for step subtrrefpha.                           *
 
6245
 *                                                              *
 
6246
 *    Bert Kampes, 09-Feb-2000                                  *
 
6247
 ****************************************************************/
 
6248
void checksubtrrefpha(
 
6249
        const input_subtrrefpha &subtrrefphainput)
 
6250
  {
 
6251
  TRACE_FUNCTION("checksubtrrefpha (BK 09-Feb-2000)")
 
6252
  INFO.print("\n\t*** Input for step SUBTRREFPHA ***");
 
6253
  // ______ Print info ______
 
6254
  switch (subtrrefphainput.method)
 
6255
    {
 
6256
    case srp_polynomial:
 
6257
      INFO.print("SRP_METHOD: \tpolynomial: \tPolynomial from COMPREFPHA used.");
 
6258
      break;
 
6259
    case srp_exact:
 
6260
      INFO.print("SRP_METHOD: \texact:      \treference phase computed foreach pixel.");
 
6261
      break;
 
6262
    default:
 
6263
      PRINT_ERROR("impossible, checked above.");
 
6264
      throw(keyword_error);
 
6265
    }
 
6266
  if (subtrrefphainput.dumponlyrefpha==false)
 
6267
    {
 
6268
    INFO << "SRP_OUT_CINT: \toutputfile complex interferogram: \t"
 
6269
       << subtrrefphainput.focint;
 
6270
    INFO.print();
 
6271
    }
 
6272
  INFO << "SRP_MULTILOOK: \tFactors (line pixel): \t" 
 
6273
       << subtrrefphainput.multilookL << " "
 
6274
       << subtrrefphainput.multilookP;
 
6275
  INFO.print();
 
6276
  if (subtrrefphainput.dumponlyrefpha==true)
 
6277
    {
 
6278
    WARNING.print("SRP_DUMPREFPHA: Only dumping reference phase, no subtraction.");
 
6279
    INFO << "SRP_DUMPREFPHA: only dump refphase: "
 
6280
         << subtrrefphainput.dumponlyrefpha;
 
6281
    INFO.print();
 
6282
    INFO << "SRP_OUT_REFPHA: Output file reference phase: "
 
6283
         << subtrrefphainput.forefpha;
 
6284
    INFO.print();
 
6285
    }
 
6286
    // __________ added by FvL
 
6287
  if (specified(subtrrefphainput.foh2ph))
 
6288
    {
 
6289
    INFO << "SRP_OUT_H2PH:   \t" << subtrrefphainput.foh2ph
 
6290
         << "; output requested of height-to-phase constant per resolution cell.";
 
6291
    INFO.print();
 
6292
    }
 
6293
  // ____________ end added by FvL
 
6294
 
 
6295
  // ______ Check ______ // [MA] increased from 100 to 1000
 
6296
  if (subtrrefphainput.multilookL > 1000 || subtrrefphainput.multilookP > 1000 ||
 
6297
      subtrrefphainput.multilookL < 1   || subtrrefphainput.multilookP < 1 )
 
6298
    WARNING.print("SRP_MULTILOOK: multilookfactor seems very high.");
 
6299
  } // END checksubtrrefpha
 
6300
 
 
6301
 
 
6302
/****************************************************************
 
6303
 *    checkresample                                             *
 
6304
 *                                                              *
 
6305
 * Checks cards for step resample.                              *
 
6306
 *                                                              *
 
6307
 *    Bert Kampes, 29-Sep-1999                                  *
 
6308
 ****************************************************************/
 
6309
void checkresample(
 
6310
        const input_resample &resampleinput)
 
6311
  {
 
6312
  TRACE_FUNCTION("checkresample (BK 29-Sep-1999)")
 
6313
  INFO.print("\n\t*** Input for step RESAMPLE ***");
 
6314
  INFO << "RS_OUT_FILE: \toutput filename: \t\t" 
 
6315
       << resampleinput.fileout;
 
6316
  INFO.print();
 
6317
  INFO << "RS_OUT_FORMAT: output format: \t\t";
 
6318
  switch (resampleinput.oformatflag)
 
6319
    {
 
6320
    case FORMATCR4:
 
6321
      INFO << "complex_real4.";
 
6322
      break;
 
6323
    case FORMATCI2:
 
6324
      INFO << "complex_short.";
 
6325
      break;
 
6326
    default:
 
6327
      PRINT_ERROR("totally impossible, checked input.");
 
6328
      throw(keyword_error);
 
6329
    }
 
6330
  INFO.print();
 
6331
  if (resampleinput.dbow.linehi != 0 || resampleinput.dbow.pixhi != 0)
 
6332
    {
 
6333
    INFO << "RS_DBOW: \tOutput window: \t\t\t" 
 
6334
         << resampleinput.dbow.linelo << " " 
 
6335
         << resampleinput.dbow.linehi << " " 
 
6336
         << resampleinput.dbow.pixlo  << " " 
 
6337
         << resampleinput.dbow.pixhi ;
 
6338
    INFO.print();
 
6339
    }
 
6340
  INFO << "RS_SHIFTAZI: \tshift azimuth spectrum: \t" 
 
6341
       << resampleinput.shiftazi ;
 
6342
  INFO.print();
 
6343
  } // END checkresample
 
6344
 
 
6345
 
 
6346
/****************************************************************
 
6347
 *    checkinterfero                                            *
 
6348
 *                                                              *
 
6349
 * Checks cards for step interfero.                             *
 
6350
 *                                                              *
 
6351
 *    Bert Kampes, 29-Sep-1999                                  *
 
6352
 ****************************************************************/
 
6353
void checkinterfero(
 
6354
        const input_interfero &interferoinput)
 
6355
  {
 
6356
  TRACE_FUNCTION("checkinterfero (BK 29-Sep-1999)")
 
6357
  INFO.print("\n\t*** Input for step INTERFERO ***");
 
6358
  bool filespecified = false;
 
6359
  bool samefilename  = false;
 
6360
  if (specified(interferoinput.foint))
 
6361
    {
 
6362
    filespecified = true;
 
6363
    INFO << "INT_OUT_INT: \tOutputfile interferogram: \t"
 
6364
         <<  interferoinput.foint;
 
6365
    INFO.print();
 
6366
    if (!(strcmp(interferoinput.foint,interferoinput.focint)))
 
6367
      samefilename = true;
 
6368
    }
 
6369
  if (specified(interferoinput.focint))
 
6370
    {
 
6371
    filespecified = true;
 
6372
    INFO << "INT_OUT_CINT: Outfile complex interferogram: \t"
 
6373
         <<  interferoinput.focint;
 
6374
    INFO.print();
 
6375
    if (!(strcmp(interferoinput.focint,interferoinput.foint)))
 
6376
      samefilename = true;
 
6377
    }
 
6378
//  if (strcmp(interferoinput.foflatearth," "))         // something is specified
 
6379
//    {
 
6380
//    filespecified = true;
 
6381
//    INFO << "INT_OUT_FE: data outputfile reference phase: \t"
 
6382
//         <<  interferoinput.foflatearth;
 
6383
//    INFO.print();
 
6384
//    if (!(strcmp(interferoinput.foflatearth,interferoinput.foint))  ||
 
6385
//        !(strcmp(interferoinput.foflatearth,interferoinput.focint)))
 
6386
//      samefilename = true;
 
6387
//    }
 
6388
 
 
6389
  INFO << "INT_MULTILOOK: \tFactor (line pixel): \t"
 
6390
       <<  interferoinput.multilookL << " " 
 
6391
       << interferoinput.multilookP;
 
6392
  INFO.print();
 
6393
  // [MA] increased from 100 to 1000
 
6394
  if (interferoinput.multilookL > 1000 || interferoinput.multilookP > 1000)
 
6395
    {
 
6396
    PRINT_ERROR("code ???: INT_MULTILOOK: > 1000.");
 
6397
    throw(keyword_error);
 
6398
    }
 
6399
  if (interferoinput.multilookL < 1 || interferoinput.multilookP < 1)
 
6400
    {
 
6401
    PRINT_ERROR("code ???: INT_MULTILOOK: < 1.");
 
6402
    throw(keyword_error);
 
6403
    }
 
6404
 
 
6405
  if (!filespecified)
 
6406
    {
 
6407
    PRINT_ERROR("code ???: INT_OUT_*: at least one output file must be specified.");
 
6408
    throw(keyword_error);
 
6409
    }
 
6410
  if (samefilename)
 
6411
    {
 
6412
    PRINT_ERROR("code ???: INT_OUT_*: same name output files.");
 
6413
    throw(keyword_error);
 
6414
    }
 
6415
  } // END checkinterfero
 
6416
 
 
6417
 
 
6418
/****************************************************************
 
6419
 *    checkcoherence                                            *
 
6420
 *                                                              *
 
6421
 * Checks cards for step coherence.                             *
 
6422
 *                                                              *
 
6423
 *    Bert Kampes, 29-Sep-1999                                  *
 
6424
 ****************************************************************/
 
6425
void checkcoherence(
 
6426
        const input_coherence &coherenceinput)
 
6427
  {
 
6428
  TRACE_FUNCTION("checkcoherence (BK 29-Sep-1999)")
 
6429
  INFO.print("\n\t*** Input for step COHERENCE ***");
 
6430
  bool filespecified = false;
 
6431
  bool samefilename  = false;
 
6432
  if (specified(coherenceinput.foccoh))
 
6433
    {
 
6434
    filespecified = true;
 
6435
    INFO << "COH_OUT_CCOH: \tOutfile complex coherence: \t"
 
6436
         <<  coherenceinput.foccoh;
 
6437
    INFO.print();
 
6438
    if (!(strcmp(coherenceinput.foccoh,coherenceinput.focoh)))
 
6439
      samefilename = true;
 
6440
    }
 
6441
 
 
6442
  if (specified(coherenceinput.focoh))
 
6443
    {
 
6444
    filespecified = true;
 
6445
    INFO << "COH_OUT_COH: \tOutputfile coherence image: "
 
6446
         <<  coherenceinput.focoh;
 
6447
    INFO.print();
 
6448
    if (!(strcmp(coherenceinput.focoh,coherenceinput.foccoh)))
 
6449
      samefilename = true;
 
6450
    }
 
6451
 
 
6452
  INFO << "COH_MULTILOOK: \tFactor (line pixel): \t"
 
6453
       <<  coherenceinput.multilookL << " "
 
6454
       << coherenceinput.multilookP;
 
6455
  INFO.print();
 
6456
  INFO << "COH_WINSIZE: \t window size coh. estimation (l/p): \t"
 
6457
       <<  coherenceinput.cohsizeL << " " << coherenceinput.cohsizeP;
 
6458
  INFO.print();
 
6459
   // [MA] increased from 100 to 1000
 
6460
  if (coherenceinput.multilookL > 1000 || coherenceinput.multilookP > 1000)
 
6461
    {
 
6462
    PRINT_ERROR("code ???: COH_MULTILOOK: > 1000.");
 
6463
    throw(keyword_error);
 
6464
    }
 
6465
  if (coherenceinput.multilookL < 1 || coherenceinput.multilookP < 1)
 
6466
    {
 
6467
    PRINT_ERROR("code ???: COH_MULTILOOK: < 1.");
 
6468
    throw(keyword_error);
 
6469
    }
 
6470
  if (coherenceinput.cohsizeL > 500 || coherenceinput.cohsizeP > 500)
 
6471
    {
 
6472
    PRINT_ERROR("code ???: COH_WINSIZE: > 500.");
 
6473
    throw(keyword_error);
 
6474
    }
 
6475
  if (coherenceinput.cohsizeL < 1 || coherenceinput.cohsizeP < 1)
 
6476
    {
 
6477
    PRINT_ERROR("code ???: COH_WINSIZE: < 1.");
 
6478
    throw(keyword_error);
 
6479
    }
 
6480
 
 
6481
  if (!filespecified)
 
6482
    {
 
6483
    PRINT_ERROR("code ???: COH_OUT_*: at least one output file must be specified.");
 
6484
    throw(keyword_error);
 
6485
    }
 
6486
  if (samefilename)
 
6487
    {
 
6488
    PRINT_ERROR("code ???: COH_OUT_*: same name output files.");
 
6489
    throw(keyword_error);
 
6490
    }
 
6491
  } // END checkcoherence
 
6492
 
 
6493
 
 
6494
 
 
6495
/****************************************************************
 
6496
 *    checkcomprefdem                                           *
 
6497
 *                                                              *
 
6498
 * Checks cards for step comprefdem.                            *
 
6499
 *                                                              *
 
6500
 *    Bert Kampes, 14-Feb-2000                                  *
 
6501
 ****************************************************************/
 
6502
void checkcomprefdem(
 
6503
        const input_comprefdem &comprefdeminput)
 
6504
  {
 
6505
  TRACE_FUNCTION("checkcomprefdem (BK 14-Feb-2000)")
 
6506
  INFO.print("\n\t*** Input for step COMPREFDEM ***");
 
6507
//  switch (comprefdeminput.method)
 
6508
//    {
 
6509
//    case crd_nearest:
 
6510
//      INFO.print("NEAREST_NEIGHBOR, use DENSE=2 or so.");
 
6511
//      break;
 
6512
//    case crd_trilinear:
 
6513
//      INFO.print("TRI_LINEAR; use DENSE=0.2 for speed.");
 
6514
//      break;
 
6515
//    default:
 
6516
//      PRINT_ERROR("totally impossible, checked input.");
 
6517
//      throw(keyword_error);
 
6518
//    }
 
6519
  INFO << "CRD_IN_DEM:    \t" << comprefdeminput.firefdem;
 
6520
  INFO.print();
 
6521
  INFO << "CRD_OUT_FILE:  \t" << comprefdeminput.forefdem;
 
6522
  INFO.print();
 
6523
  if (specified(comprefdeminput.forefdemhei))
 
6524
    {
 
6525
    INFO << "CRD_OUT_DEM_LP: \t" << comprefdeminput.forefdemhei
 
6526
       << "; output requested of DEM [m] in radar coordinates.";
 
6527
    INFO.print();
 
6528
    if (!strcmp(comprefdeminput.forefdem,comprefdeminput.forefdemhei))
 
6529
      {
 
6530
      PRINT_ERROR("CRD_OUT_FILE, CRD_OUT_DEM_LP: Same output file name.");
 
6531
      throw(keyword_error);
 
6532
      }
 
6533
    }
 
6534
  if (specified(comprefdeminput.fodem))
 
6535
    {
 
6536
    INFO << "CRD_OUT_DEM:   \t" << comprefdeminput.fodem
 
6537
       << "; output requested of input DEM.";
 
6538
    INFO.print();
 
6539
    if (!strcmp(comprefdeminput.fodemi,comprefdeminput.fodem))
 
6540
      {
 
6541
      PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
 
6542
      throw(keyword_error);
 
6543
      }
 
6544
    }
 
6545
  if (specified(comprefdeminput.fodemi))
 
6546
    {
 
6547
    INFO << "CRD_OUT_DEMI:   \t" << comprefdeminput.fodemi
 
6548
         << "; output requested of interpolated DEM.";
 
6549
    INFO.print();
 
6550
    if (!strcmp(comprefdeminput.fodemi,comprefdeminput.fodem))
 
6551
      {
 
6552
      PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
 
6553
      throw(keyword_error);
 
6554
      }
 
6555
    }
 
6556
    // __________ added by FvL
 
6557
  if (specified(comprefdeminput.foh2ph))
 
6558
    {
 
6559
    INFO << "CRD_OUT_H2PH:   \t" << comprefdeminput.foh2ph
 
6560
         << "; output requested of height-to-phase constant per resolution cell.";
 
6561
    INFO.print();
 
6562
    }
 
6563
  // ____________ end added by FvL
 
6564
  INFO << "CRD_IN_SIZE:   \t" << comprefdeminput.demrows
 
6565
       << " " << comprefdeminput.demcols
 
6566
       << "; number of rows (latitude), columns (lon) in DEM.";
 
6567
  INFO.print();
 
6568
  INFO << "CRD_IN_UL:     \t" 
 
6569
       << rad2deg(comprefdeminput.demlatleftupper) << " "
 
6570
       << rad2deg(comprefdeminput.demlonleftupper)
 
6571
       << "; coordinates of upper left corner (first row/col).";
 
6572
  INFO.print();
 
6573
  INFO << "CRD_IN_DELTA:  \t"
 
6574
       << rad2deg(comprefdeminput.demdeltalat) << " "
 
6575
       << rad2deg(comprefdeminput.demdeltalon);
 
6576
  INFO.print();
 
6577
  INFO << "CRD_IN_NODATA:  \t" << comprefdeminput.demnodata
 
6578
       << "; this number in DEM will be set to 0 reference phase.";
 
6579
  INFO.print();
 
6580
//  INFO << "CRD_DENSE:      \t" << comprefdeminput.extradense
 
6581
//       << "; this is the factor for oversampling DEM more than minimum.";
 
6582
//  INFO.print();
 
6583
  if (comprefdeminput.includerefpha)
 
6584
    INFO << "CRD_INCLUDE_FE: \tref. dem is computed including flat earth.";
 
6585
  else
 
6586
    INFO << "CRD_INCLUDE_FE: \tref. dem is computed w.r.t. ellipsoid (topo only).";
 
6587
  INFO.print();
 
6588
 
 
6589
  INFO << "CRD_IN_FORMAT: \tinput format DEM: \t";
 
6590
  switch (comprefdeminput.iformatflag)
 
6591
    {
 
6592
    case FORMATR4:
 
6593
      INFO << "real4.";
 
6594
      break;
 
6595
    case FORMATR8:
 
6596
      INFO << "real8.";
 
6597
      break;
 
6598
    case FORMATI2:
 
6599
      INFO << "signed short.";
 
6600
      break;
 
6601
    case FORMATI2_BIGENDIAN:
 
6602
      INFO << "signed short big endian.";
 
6603
      break;
 
6604
    default:
 
6605
      PRINT_ERROR("totally impossible, checked input.");
 
6606
      throw(keyword_error);
 
6607
    }
 
6608
  INFO.print();
 
6609
 
 
6610
 
 
6611
 
 
6612
// ______ Check some things ______
 
6613
  if (!existed(comprefdeminput.firefdem))
 
6614
    {
 
6615
    ERROR << "CRD_IN_DEM:   \t" << comprefdeminput.firefdem
 
6616
         << " can not be opened.";
 
6617
    PRINT_ERROR(ERROR.get_str())
 
6618
    throw(keyword_error);
 
6619
    }
 
6620
  if (rad2deg(comprefdeminput.demdeltalat)<.0002) //[MA] 1 arc secs = 1/3600=0.00027 : allow finer resolutions
 
6621
    {
 
6622
    WARNING << "CRD_IN_DELTA: \t" << rad2deg(comprefdeminput.demdeltalat)
 
6623
         << " [deg] seems very small (input in decimal degrees).";
 
6624
    WARNING.print();
 
6625
    }
 
6626
  if (comprefdeminput.demrows<1 || comprefdeminput.demrows>100000)
 
6627
    {
 
6628
    WARNING << "CRD_DEM_SIZE: numrows: \t" << comprefdeminput.demrows
 
6629
         << " seems to be wrong.";
 
6630
    WARNING.print();
 
6631
    }
 
6632
  if (comprefdeminput.demcols<1 || comprefdeminput.demcols>100000)
 
6633
    {
 
6634
    WARNING << "CRD_DEM_SIZE: numcols: \t" << comprefdeminput.demcols
 
6635
         << " seems to be wrong.";
 
6636
    WARNING.print();
 
6637
    }
 
6638
//  if (comprefdeminput.extradense>5.0)
 
6639
//    {
 
6640
//    WARNING << "CRD_DENSE:    \t" << comprefdeminput.extradense
 
6641
//         << " seems to be quite large.";
 
6642
//    WARNING.print();
 
6643
//    }
 
6644
//  if (comprefdeminput.extradense<0.2)
 
6645
//    {
 
6646
//    WARNING << "CRD_DENSE:    \t" << comprefdeminput.extradense
 
6647
//         << " seems too small.";
 
6648
//    WARNING.print();
 
6649
//    }
 
6650
  if (rad2deg(comprefdeminput.demdeltalon)<.0002)
 
6651
    {
 
6652
    WARNING << "CRD_IN_DELTA: \t" << comprefdeminput.demdeltalon
 
6653
         << " seems very small (it should be in decimal degrees).";
 
6654
    WARNING.print();
 
6655
    }
 
6656
  if (rad2deg(comprefdeminput.demlatleftupper) < -90. ||
 
6657
      rad2deg(comprefdeminput.demlatleftupper) >  90.   )
 
6658
    {
 
6659
    ERROR << "CRD_IN_LU:    \t" << rad2deg(comprefdeminput.demlatleftupper)
 
6660
         << " out of range (-90:90).";
 
6661
    PRINT_ERROR(ERROR.get_str())
 
6662
    throw(keyword_error);
 
6663
    }
 
6664
  if (rad2deg(comprefdeminput.demlonleftupper) < -180. ||
 
6665
      rad2deg(comprefdeminput.demlonleftupper) >  180.   )
 
6666
    {
 
6667
    WARNING << "CRD_IN_LU:    \t" << rad2deg(comprefdeminput.demlonleftupper)
 
6668
         << " out of range (-180:180).";
 
6669
    WARNING.print();
 
6670
    }
 
6671
  if (!strcmp(comprefdeminput.fodem,comprefdeminput.forefdem))
 
6672
    {
 
6673
    PRINT_ERROR("OUT_DEM, OUT_FILE: Same output file name.");
 
6674
    throw(keyword_error);
 
6675
    }
 
6676
  if (!strcmp(comprefdeminput.firefdem,comprefdeminput.forefdem))
 
6677
    {
 
6678
    PRINT_ERROR("OUT_FILE, IN_DEM: Same file name.");
 
6679
    throw(keyword_error);
 
6680
    }
 
6681
  } // END comprefdem
 
6682
 
 
6683
 
 
6684
 
 
6685
/****************************************************************
 
6686
 *    checksubtrrefdem                                          *
 
6687
 *                                                              *
 
6688
 * Checks cards for step subtrrefdem.                           *
 
6689
 *                                                              *
 
6690
 *    Bert Kampes, 14-Feb-2000                                  *
 
6691
 ****************************************************************/
 
6692
void checksubtrrefdem(
 
6693
        const input_subtrrefdem &subtrrefdeminput)
 
6694
  {
 
6695
  TRACE_FUNCTION("checksubtrrefdem (BK 14-Feb-2000)")
 
6696
  INFO.print("\n\t*** Input for step SUBTRREFDEM ***");
 
6697
  INFO << "SRD_OUT_CINT:   \t" << subtrrefdeminput.focint;
 
6698
  INFO.print();
 
6699
  INFO << "SRD_OFFSET:     \t" << subtrrefdeminput.offsetL 
 
6700
       << " " << subtrrefdeminput.offsetP;
 
6701
  INFO.print();
 
6702
  if (abs(subtrrefdeminput.offsetL)>5) 
 
6703
    WARNING.print("Apply offset in azimuth larger than 5 pixels?");
 
6704
  if (abs(subtrrefdeminput.offsetP)>5) 
 
6705
    WARNING.print("Apply offset in range larger than 5 pixels?");
 
6706
  } // END checksubtrrefdem
 
6707
 
 
6708
 
 
6709
/****************************************************************
 
6710
 *    checkfiltrange                                            *
 
6711
 * Checks cards for step filtrange.                             *
 
6712
 *    Bert Kampes, 14-Feb-2000                                  *
 
6713
 ****************************************************************/
 
6714
void checkfiltrange(
 
6715
        const input_filtrange &filtrangeinput)
 
6716
  {
 
6717
  TRACE_FUNCTION("checkfiltrange (BK 14-Feb-2000)")
 
6718
  INFO.print("\n\t*** Input for step FILTRANGE ***");
 
6719
  // ______ Give info ______
 
6720
  switch (filtrangeinput.method)
 
6721
    {
 
6722
    case rf_adaptive:
 
6723
      INFO.print("RF_METHOD:        ADAPTIVE \t(estimate fringe freq.)");
 
6724
      INFO << "RF_NLMEAN:     " << filtrangeinput.nlmean;
 
6725
      INFO.print();
 
6726
      INFO << "RF_THRESHOLD:  " << filtrangeinput.SNRthreshold;
 
6727
      INFO.print();
 
6728
      INFO << "RF_OVERSAMPLE: " << filtrangeinput.oversample;
 
6729
      INFO.print();
 
6730
      INFO << "RF_WEIGHTCORR: " << filtrangeinput.doweightcorrel;
 
6731
      INFO.print();
 
6732
      INFO << "RF_OVERLAP:    " << filtrangeinput.overlap;
 
6733
      INFO.print();
 
6734
      if (filtrangeinput.nlmean > 51)
 
6735
        WARNING.print("RF_NLMEAN:     mean over more than 51 lines (?)");
 
6736
      if (filtrangeinput.SNRthreshold<1.99)
 
6737
        WARNING.print("RF_THRESHOLD:  < 2");
 
6738
      if (filtrangeinput.SNRthreshold>10.01)
 
6739
        WARNING.print("RF_THRESHOLD:  > 10 ?");
 
6740
      if (filtrangeinput.oversample<=1)
 
6741
        WARNING.print("RF_OVERSAMPLE: no oversampling.");
 
6742
      if (filtrangeinput.oversample>8)
 
6743
        WARNING.print("RF_OVERSAMPLE: >8 ?");
 
6744
      if (!ispower2(filtrangeinput.oversample))
 
6745
        WARNING.print("RF_OVERSAMPLE: not power of two.");
 
6746
      if (filtrangeinput.doweightcorrel==true)
 
6747
        WARNING.print("RF_WEIGHTCORR: weighting, not sure it has effect.");
 
6748
      if (filtrangeinput.fftlength > 1024)
 
6749
        WARNING.print("RF_FFTLENGTH:  adaptive filterlength > 1024 ?");
 
6750
      if (filtrangeinput.SNRthreshold<0.)
 
6751
        {
 
6752
        PRINT_ERROR(  "RF_THRESHOLD:  < 0.");
 
6753
        throw(keyword_error);
 
6754
        }
 
6755
      break;
 
6756
    case rf_porbits:
 
6757
      INFO.print("RF_METHOD:        PORBITS  \t(based on orbits.)");
 
6758
      INFO << "RF_SLOPE:      " << rad2deg(filtrangeinput.terrainslope)
 
6759
           << "\t[deg] terrainslope.";
 
6760
      INFO.print();
 
6761
      if (filtrangeinput.fftlength < 256)
 
6762
        WARNING.print("RF_FFTLENGTH:  porbits filterlength < 256 (?)");
 
6763
      break;
 
6764
    default:
 
6765
      PRINT_ERROR("totally impossible, checked input.");
 
6766
      throw(keyword_error);
 
6767
    }
 
6768
  // ______ Both methods cards ______
 
6769
  INFO << "RF_FFTLENGTH:  " << filtrangeinput.fftlength;
 
6770
  INFO.print();
 
6771
  INFO << "RF_HAMMING:    " << filtrangeinput.hammingalpha;
 
6772
  INFO.print();
 
6773
  INFO << "RF_OUT_MASTER: " << filtrangeinput.fomaster;
 
6774
  INFO.print();
 
6775
  INFO << "RF_OUT_SLAVE:  " << filtrangeinput.foslave;
 
6776
  INFO.print();
 
6777
  INFO << "RF_OUT_FORMAT: output format: ";
 
6778
  switch (filtrangeinput.oformatflag)
 
6779
    {
 
6780
    case FORMATCR4:
 
6781
      INFO << "complex_real4.";
 
6782
      break;
 
6783
    case FORMATCI2:
 
6784
      INFO << "complex_short.";
 
6785
      break;
 
6786
    default:
 
6787
      PRINT_ERROR("totally impossible, checked input.");
 
6788
      throw(keyword_error);
 
6789
    }
 
6790
  INFO.print();
 
6791
 
 
6792
  // ______ Check input ______
 
6793
  if (filtrangeinput.hammingalpha>0.999)
 
6794
    WARNING.print("RF_HAMMING: no hamming filtering.");
 
6795
  if (existed(filtrangeinput.fomaster))
 
6796
    WARNING.print("RF_OUT_MASTER: file exists.");
 
6797
  if (existed(filtrangeinput.foslave))
 
6798
    WARNING.print("RF_OUT_SLAVE: file exists.");
 
6799
  if (!ispower2(filtrangeinput.fftlength))
 
6800
    {
 
6801
    PRINT_ERROR(  "RF_FFTLENGTH: not power of 2.");
 
6802
    throw(keyword_error);
 
6803
    }
 
6804
  if (filtrangeinput.overlap >= 0.5*filtrangeinput.fftlength)
 
6805
    {
 
6806
    PRINT_ERROR(  "RF_OVERLAP >= 0.5*RF_FFTLENGTH");
 
6807
    throw(keyword_error);
 
6808
    }
 
6809
  if (filtrangeinput.hammingalpha>1. || filtrangeinput.hammingalpha<0.)
 
6810
    {
 
6811
    PRINT_ERROR(  "RF_HAMMING: not e[0,1].");
 
6812
    throw(keyword_error);
 
6813
    }
 
6814
  } // END checkfiltrange
 
6815
 
 
6816
 
 
6817
 
 
6818
/****************************************************************
 
6819
 *    checkdinsar                                               *
 
6820
 *                                                              *
 
6821
 * Checks cards for step dinsar.                                *
 
6822
 *                                                              *
 
6823
 #%// BK 25-Sep-2000
 
6824
 ****************************************************************/
 
6825
void checkdinsar(
 
6826
        const input_dinsar &dinsarinput)
 
6827
  {
 
6828
  TRACE_FUNCTION("checkdinsar (BK 25-Sep-2000)")
 
6829
  INFO.print("\n\t*** Input for step DINSAR ***");
 
6830
 
 
6831
  if (!specified(dinsarinput.topomasterresfile))
 
6832
    {
 
6833
    INFO.print("Using 3 pass differential (for 4 pass, see DI_IN_TOPOMASTER card).");
 
6834
    }
 
6835
  else
 
6836
    {
 
6837
    INFO << "DI_IN_TOPOMASTER: \t" << dinsarinput.topomasterresfile
 
6838
         << " (4 pass)";
 
6839
    INFO.print();
 
6840
    }
 
6841
  INFO << "DI_IN_TOPOSLAVE: \t" << dinsarinput.toposlaveresfile;
 
6842
  INFO.print();
 
6843
  INFO << "DI_IN_TOPOINT:   \t" << dinsarinput.topointresfile;
 
6844
  INFO.print();
 
6845
  INFO << "DI_OUT_FILE:     \t" << dinsarinput.fodinsar;
 
6846
  INFO.print();
 
6847
  if (!specified(dinsarinput.foscaleduint))
 
6848
    INFO << "DI_OUT_SCALED: \tNo (debug) output requested scaled topography interf.";
 
6849
  else
 
6850
    INFO << "DI_OUT_SCALED: \t" << dinsarinput.foscaleduint 
 
6851
         << "; debug output requested.";
 
6852
  INFO.print();
 
6853
  if (!specified(dinsarinput.toposlaveresfile))
 
6854
    {
 
6855
    PRINT_ERROR("DI_IN_TOPOSLAVE: result file topo slave not specified.");
 
6856
    throw(keyword_error);
 
6857
    }
 
6858
  if (!specified(dinsarinput.topointresfile))
 
6859
    {
 
6860
    PRINT_ERROR("DI_IN_TOPOINT: result file topo interferogram not specified.");
 
6861
    throw(keyword_error);
 
6862
    }
 
6863
  if (!strcmp(dinsarinput.toposlaveresfile,dinsarinput.topointresfile))
 
6864
    {
 
6865
    PRINT_ERROR("IN_TOPOSLAVE, IN_TOPOINT: Same input file name.");
 
6866
    throw(keyword_error);
 
6867
    }
 
6868
  } // END checkdinsar
 
6869
 
 
6870
 
 
6871
 
 
6872
/****************************************************************
 
6873
 *    checkfiltphase                                            *
 
6874
 *                                                              *
 
6875
 * Checks cards for step filtphase.                             *
 
6876
 *                                                              *
 
6877
 #%// BK 25-Sep-2000
 
6878
 ****************************************************************/
 
6879
void checkfiltphase(
 
6880
        const input_filtphase &filtphaseinput)
 
6881
  {
 
6882
  TRACE_FUNCTION("checkfiltphase (BK 25-Sep-2000)")
 
6883
  INFO.print("\n\t*** Input for step FILTPHASE ***");
 
6884
  if (specified(filtphaseinput.fifiltphase))
 
6885
    {
 
6886
    INFO << "PF_IN_FILE: \t" << filtphaseinput.fifiltphase
 
6887
         << " " <<  filtphaseinput.finumlines
 
6888
         << " (this cr4 file will be filtered)";
 
6889
    INFO.print();
 
6890
    if (!existed(filtphaseinput.fifiltphase))
 
6891
      WARNING.print("Impossible? PF input file does not exist?");
 
6892
    }
 
6893
  INFO << "PF_OUT_FILE: \t" << filtphaseinput.fofiltphase 
 
6894
       << " (output filename).";
 
6895
  INFO.print();
 
6896
 
 
6897
  // ______ Method goldstein filter ______
 
6898
  if (filtphaseinput.method==fp_goldstein)
 
6899
    {
 
6900
    INFO.print("FILTPHASE: Method goldstein.");
 
6901
    INFO << "PF_ALPHA: \t" << filtphaseinput.alpha
 
6902
         << " (weigthing parameter for spectrum).";
 
6903
    INFO.print();
 
6904
    INFO << "PF_BLOCKSIZE: " << filtphaseinput.blocksize
 
6905
         << " (size of block to perform filtering on).";
 
6906
    INFO.print();
 
6907
    INFO << "PF_OVERLAP: \t" << filtphaseinput.overlap
 
6908
         << " (half overlap between consequetive blocks).";
 
6909
    INFO.print();
 
6910
 
 
6911
    // ______ Use 1d kernel to smooth amplitude, e.g. 12321 ______
 
6912
    // ______ Which is normalized by me ______
 
6913
    INFO << "PF_KERNEL: \t";
 
6914
    for (int32 ii=0; ii<filtphaseinput.kernel.pixels(); ++ii)
 
6915
      INFO << " " << filtphaseinput.kernel(0,ii);
 
6916
    INFO << " (smooth |spectrum| with this).";
 
6917
    INFO.print();
 
6918
    if (filtphaseinput.kernel.pixels()==1)
 
6919
      INFO.print("No smoothing of amplitude spectrum!");
 
6920
 
 
6921
    // ______ Check errors _____
 
6922
    if (filtphaseinput.alpha<0. || filtphaseinput.alpha>1.)
 
6923
      WARNING.print("PF_ALPHA not 0<a<1");
 
6924
    if (filtphaseinput.blocksize>64 || filtphaseinput.blocksize<16)
 
6925
      WARNING.print("PF_BLOCKSIZE very small or large?");
 
6926
    if (filtphaseinput.kernel.pixels()>11)
 
6927
      WARNING.print("smoothing kernel > 11:  very large?");
 
6928
    if (filtphaseinput.overlap<0)
 
6929
      {
 
6930
      PRINT_ERROR("PF_OVERLAP < 0");
 
6931
      throw(keyword_error);
 
6932
      }
 
6933
    if (2*filtphaseinput.overlap>filtphaseinput.blocksize)
 
6934
      {
 
6935
      PRINT_ERROR("2*PF_OVERLAP > PF_BLOCKSIZE");
 
6936
      throw(keyword_error);
 
6937
      }
 
6938
    if (filtphaseinput.kernel.pixels()>filtphaseinput.blocksize)
 
6939
      {
 
6940
      PRINT_ERROR("smoothing kernel > PF_BLOCKSIZE");
 
6941
      throw(keyword_error);
 
6942
      }
 
6943
    if (!ispower2(filtphaseinput.blocksize))
 
6944
      {
 
6945
      PRINT_ERROR("PF_BLOCKSIZE not a power of 2");
 
6946
      throw(keyword_error);
 
6947
      }
 
6948
    }
 
6949
 
 
6950
  // ______ Method modified goldstein filter ______
 
6951
  else if (filtphaseinput.method==fp_modgoldstein)
 
6952
    {
 
6953
    INFO.print("FILTPHASE: Method modgoldstein.");
 
6954
    INFO << "PF_ALPHA: \t" << -1
 
6955
         << " (Calculated based on coherence).";
 
6956
    INFO.print();
 
6957
    INFO << "PF_BLOCKSIZE: " << filtphaseinput.blocksize
 
6958
         << " (size of block to perform filtering on).";
 
6959
    INFO.print();
 
6960
    INFO << "PF_OVERLAP: \t" << filtphaseinput.overlap
 
6961
         << " (half overlap between consequetive blocks).";
 
6962
    INFO.print();
 
6963
 
 
6964
    // ______ Use 1d kernel to smooth amplitude, e.g. 12321 ______
 
6965
    // ______ Which is normalized by me ______
 
6966
    INFO << "PF_KERNEL: \t";
 
6967
    for (int32 ii=0; ii<filtphaseinput.kernel.pixels(); ++ii)
 
6968
      INFO << " " << filtphaseinput.kernel(0,ii);
 
6969
    INFO << " (smooth |spectrum| with this).";
 
6970
    INFO.print();
 
6971
    if (filtphaseinput.kernel.pixels()==1)
 
6972
      INFO.print("No smoothing of amplitude spectrum!");
 
6973
 
 
6974
    // ______ Check errors _____
 
6975
    if (filtphaseinput.alpha<0. || filtphaseinput.alpha>1.)
 
6976
      WARNING.print("PF_ALPHA not 0<a<1");
 
6977
    if (filtphaseinput.blocksize>64 || filtphaseinput.blocksize<16)
 
6978
      WARNING.print("PF_BLOCKSIZE very small or large?");
 
6979
    if (filtphaseinput.kernel.pixels()>11)
 
6980
      WARNING.print("smoothing kernel > 11:  very large?");
 
6981
    if (filtphaseinput.overlap<0)
 
6982
      {
 
6983
      PRINT_ERROR("PF_OVERLAP < 0");
 
6984
      throw(keyword_error);
 
6985
      }
 
6986
    if (2*filtphaseinput.overlap>filtphaseinput.blocksize)
 
6987
      {
 
6988
      PRINT_ERROR("2*PF_OVERLAP > PF_BLOCKSIZE");
 
6989
      throw(keyword_error);
 
6990
      }
 
6991
    if (filtphaseinput.kernel.pixels()>filtphaseinput.blocksize)
 
6992
      {
 
6993
      PRINT_ERROR("smoothing kernel > PF_BLOCKSIZE");
 
6994
      throw(keyword_error);
 
6995
      }
 
6996
    if (!ispower2(filtphaseinput.blocksize))
 
6997
      {
 
6998
      PRINT_ERROR("PF_BLOCKSIZE not a power of 2");
 
6999
      throw(keyword_error);
 
7000
      }
 
7001
    }
 
7002
 
 
7003
  // ______ Method spatial convolution ______
 
7004
  else if (filtphaseinput.method==fp_spatialconv)
 
7005
    {
 
7006
    INFO.print("FILTPHASE: Method spatial convolution.");
 
7007
    if (!specified(filtphaseinput.fikernel2d))
 
7008
      {
 
7009
      INFO.print("Using 1d kernel for spatial convolution (no PF_IN_KERNEL2D).");
 
7010
      INFO << "PF_KERNEL: used: \t";
 
7011
      for (int32 ii=0; ii<filtphaseinput.kernel.pixels(); ++ii)
 
7012
        INFO << " " << filtphaseinput.kernel(0,ii);
 
7013
      INFO.print();
 
7014
      }
 
7015
    else
 
7016
      {
 
7017
      INFO.print("Using 2d kernel for spatial convolution.");
 
7018
      INFO << "PF_IN_KERNEL2D: \t" << filtphaseinput.fikernel2d
 
7019
           << " (ascii input file with 2d kernel).";
 
7020
      INFO.print();
 
7021
      INFO.print("PF_IN_KERNEL2D: \t(input file has 1 line header: numrows numcols scale");
 
7022
      if (filtphaseinput.kernel.size()!=0)
 
7023
        WARNING.print("PF_KERNEL card ignored due to card PF_IN_KERNEL2D.");
 
7024
      if (!existed(filtphaseinput.fikernel2d))
 
7025
        WARNING.print("PF_IN_KERNEL2D infile cannot be found.");
 
7026
      }
 
7027
    }
 
7028
  else if (filtphaseinput.method==fp_spectral)
 
7029
    {
 
7030
    INFO.print("FILTPHASE: Method spectral filter with 2D kernel.");
 
7031
    INFO << "PF_BLOCKSIZE: " << filtphaseinput.blocksize
 
7032
         << " (size of block to perform filtering on).";
 
7033
    INFO.print();
 
7034
    INFO << "PF_OVERLAP: \t" << filtphaseinput.overlap
 
7035
         << " (half overlap between consequetive blocks).";
 
7036
    INFO.print();
 
7037
    if (filtphaseinput.kernel.size()!=0)
 
7038
      WARNING.print("PF_KERNEL card ignored for method spectral.");
 
7039
    if (filtphaseinput.overlap<0)
 
7040
      {
 
7041
      PRINT_ERROR("PF_OVERLAP < 0");
 
7042
      throw(keyword_error);
 
7043
      }
 
7044
    if (2*filtphaseinput.overlap>filtphaseinput.blocksize)
 
7045
      {
 
7046
      PRINT_ERROR("2*PF_OVERLAP > PF_BLOCKSIZE");
 
7047
      throw(keyword_error);
 
7048
      }
 
7049
    if (!ispower2(filtphaseinput.blocksize))
 
7050
      {
 
7051
      PRINT_ERROR("PF_BLOCKSIZE not a power of 2");
 
7052
      throw(keyword_error);
 
7053
      }
 
7054
    if (!specified(filtphaseinput.fikernel2d))
 
7055
      {
 
7056
      PRINT_ERROR("method spectral needs card PF_IN_KERNEL2D");
 
7057
      throw(keyword_error);
 
7058
      }
 
7059
    }
 
7060
  else
 
7061
    {
 
7062
    PRINT_ERROR("Method phasefiltering != {goldstein,modgolstein,spatialconv,spectral}.");
 
7063
    throw(keyword_error);
 
7064
    }
 
7065
  } // END checkfiltphase
 
7066
 
 
7067
 
 
7068
/****************************************************************
 
7069
 *    checkfiltazi                                              *
 
7070
 * Checks cards for step filtazi.                               *
 
7071
 *    Bert Kampes, 02-Nov-2000                                  *
 
7072
 ****************************************************************/
 
7073
void checkfiltazi(
 
7074
        const input_filtazi &filtaziinput,
 
7075
        const int16 id)         // either master, slave, or m+s
 
7076
  {
 
7077
  TRACE_FUNCTION("checkfiltazi (BK 02-Nov-2000)")
 
7078
  INFO.print("\n\t*** Input for step FILTAZI ***");
 
7079
  INFO << "AF_BLOCKSIZE:   \t" << filtaziinput.fftlength;
 
7080
  INFO.print();
 
7081
  INFO << "AF_OVERLAP:     \t" << filtaziinput.overlap;
 
7082
  INFO.print();
 
7083
  INFO << "AF_HAMMING:     \t" << filtaziinput.hammingalpha;
 
7084
  INFO.print();
 
7085
  if (filtaziinput.oformatflag==FORMATCR4)
 
7086
    INFO.print("AF_OUT_FORMAT:  \tcomplex_real4");
 
7087
  else if (filtaziinput.oformatflag==FORMATCI2)
 
7088
    INFO.print("AF_OUT_FORMAT:  \tcomplex_short");
 
7089
  else
 
7090
    {
 
7091
    PRINT_ERROR("formatflag not ok for output.");
 
7092
    throw(keyword_error);
 
7093
    }
 
7094
 
 
7095
  if (id!=SLAVEID)
 
7096
    {
 
7097
    INFO << "AF_OUT_MASTER:  \t" << filtaziinput.fomaster;
 
7098
    INFO.print();
 
7099
    }
 
7100
  if (id!=MASTERID)
 
7101
    {
 
7102
    INFO << "AF_OUT_SLAVE:   \t" << filtaziinput.foslave;
 
7103
    INFO.print();
 
7104
    }
 
7105
 
 
7106
  if (filtaziinput.fftlength<256)
 
7107
    WARNING.print("AF_BLOCKSIZE < 256 (too small?)");
 
7108
  if (2*filtaziinput.overlap>0.5*filtaziinput.fftlength)
 
7109
    WARNING.print("2*AF_OVERLAP > .5*AF_BLOCKSIZE (very large?)");
 
7110
  if (filtaziinput.hammingalpha<0 || filtaziinput.hammingalpha>1)
 
7111
    {
 
7112
    PRINT_ERROR("AF_HAMMING not e[0,1]");
 
7113
    throw(keyword_error);
 
7114
    }
 
7115
  if (filtaziinput.overlap<0)
 
7116
    {
 
7117
    PRINT_ERROR("AF_BLOCKSIZE < 0");
 
7118
    throw(keyword_error);
 
7119
    }
 
7120
  if (2*filtaziinput.overlap>filtaziinput.fftlength)
 
7121
    {
 
7122
    PRINT_ERROR("AF_BLOCKSIZE < 2*AF_BLOCKSIZE");
 
7123
    throw(keyword_error);
 
7124
    }
 
7125
  if (!ispower2(filtaziinput.fftlength))
 
7126
    {
 
7127
    PRINT_ERROR("AF_BLOCKSIZE must be power of 2.");
 
7128
    throw(keyword_error);
 
7129
    }
 
7130
  } // END checkfiltazi
 
7131
 
 
7132