source: issm/trunk-jpl/src/py3/classes/flaim.py@ 19895

Last change on this file since 19895 was 19895, checked in by bdef, 9 years ago

NEW:Adding directory to hold the python 3 implementation of the interface

File size: 3.3 KB
Line 
1import numpy
2from collections import OrderedDict
3from fielddisplay import fielddisplay
4from EnumDefinitions import *
5from checkfield import checkfield
6from WriteData import WriteData
7
8class flaim(object):
9 """
10 FLAIM class definition
11
12 Usage:
13 flaim=flaim();
14 """
15
16 def __init__(self): # {{{
17 self.targets = ''
18 self.tracks = ''
19 self.flightreqs = OrderedDict()
20 self.criterion = float('NaN')
21 self.gridsatequator = 200000
22 self.usevalueordering = True
23 self.split_antimeridian = True
24 self.solution = ''
25 self.quality = 0
26 self.path_optimize = False
27 self.opt_ndir = 1
28 self.opt_dist = 25
29 self.opt_niter = 30000
30 #}}}
31 def __repr__(self): # {{{
32 string=' FLAIM - Flight Line Adaptation using Ice sheet Modeling:'
33
34 string="%s\n\n%s"%(string,' Input:')
35 string="%s\n%s"%(string,fielddisplay(self,'targets' ,'name of kml output targets file '))
36 string="%s\n%s"%(string,fielddisplay(self,'tracks' ,'name of kml input tracks file '))
37 string="%s\n%s"%(string,fielddisplay(self,'flightreqs' ,'structure of kml flight requirements (not used yet)'))
38 string="%s\n%s"%(string,fielddisplay(self,'criterion' ,'element or nodal criterion for flight path evaluation (metric)'))
39
40 string="%s\n\n%s"%(string,' Arguments:')
41 string="%s\n%s"%(string,fielddisplay(self,'gridsatequator' ,'number of grids at equator (determines resolution)'))
42 string="%s\n%s"%(string,fielddisplay(self,'usevalueordering' ,'flag to consider target values for flight path evaluation'))
43 string="%s\n%s"%(string,fielddisplay(self,'split_antimeridian' ,'flag to split polygons on the antimeridian'))
44
45 string="%s\n\n%s"%(string,' Optimization:')
46 string="%s\n%s"%(string,fielddisplay(self,'path_optimize' ,'optimize? (default false)'))
47 string="%s\n%s"%(string,fielddisplay(self,'opt_ndir' ,['number of directions to test when moving a point. If this value = 1, a random direction is tested.',\
48 'A value > 1 results in directions equally spaced from [0, 2*PI] being tested.',\
49 'For example, 4 would result in directions [0, PI/2, PI, 3PI/2].']))
50 string="%s\n%s"%(string,fielddisplay(self,'opt_dist' ,'specifies the distance in km (default 25) to move a randomly selected path point on each iteration'))
51 string="%s\n%s"%(string,fielddisplay(self,'opt_niter' ,['number of iterations (default 30,000) to run for flightplan optimization',\
52 'i.e. the number of times to randomly select a point and move it.']))
53
54 string="%s\n\n%s"%(string,' Output:')
55 string="%s\n%s"%(string,fielddisplay(self,'solution' ,'name of kml solution file'))
56 string="%s\n%s"%(string,fielddisplay(self,'quality' ,'quality of kml solution'))
57 return string
58 #}}}
59 def checkconsistency(self,md,solution,analyses): # {{{
60
61 #Early return
62 if not solution==FlaimSolutionEnum():
63 return md
64
65 md = checkfield(md,'fieldname','flaim.tracks','file',1)
66 if numpy.any(numpy.isnan(md.flaim.criterion)) or not md.flaim.criterion:
67 md = checkfield(md,'fieldname','flaim.targets','file',1)
68 else:
69 md = checkfield(md,'fieldname','flaim.criterion','numel',[md.mesh.numberofvertices,md.mesh.numberofelements])
70
71 return md
72 # }}}
Note: See TracBrowser for help on using the repository browser.