@@ -32,35 +32,38 @@ def __init__(
32
32
33
33
@classmethod
34
34
def open (cls , path , crs = None , fmt = "grd" ):
35
- assert fmt .lower () in ['grd' , 'gr3' , 'adcirc' , 'schism' , '2dm' , 'sms' ,
36
- 'msh' ]
35
+ assert fmt .lower () in [
36
+ 'grd' , 'gr3' , 'adcirc' , 'schism' ,
37
+ # '2dm', 'sms',
38
+ # 'msh'
39
+ ]
37
40
38
41
if fmt .lower () in ['grd' , 'gr3' , 'adcirc' , 'schism' ]:
39
42
return cls .open_grd (path , crs )
40
43
41
- elif fmt .lower () in ['2dm' , 'sms' ]:
42
- return cls .open_2dm (path , crs )
44
+ # elif fmt.lower() in ['2dm', 'sms']:
45
+ # return cls.open_2dm(path, crs)
43
46
44
- @classmethod
45
- def open_2dm (cls , path , crs = None ):
46
- raise NotImplementedError
47
+ # @classmethod
48
+ # def open_2dm(cls, path, crs=None):
49
+ # raise NotImplementedError
47
50
48
51
@classmethod
49
52
def open_grd (cls , path , crs = None ):
50
- _grd = grd .reader (path )
51
- _grd . pop ( 'boundaries' )
52
- return cls .from_grd (_grd , crs )
53
+ grid = grd .reader (path )
54
+ grid . update ({ "crs" : crs } )
55
+ return cls .from_grd (grid )
53
56
54
57
@classmethod
55
58
def open_gr3 (cls , path , crs = None ):
56
59
return cls .open_grd (path , crs )
57
60
58
61
@classmethod
59
- def from_grd (cls , grid , crs = None ):
60
- grid = grd . to_gmesh ( grid )
61
- if 'boundaries' in grid :
62
- grid . pop ( 'boundaries' )
63
- return cls (** grid , crs = crs )
62
+ def from_grd (cls , grid ):
63
+ """
64
+ grd is a dictionary of of the form :
65
+ """
66
+ return cls (** grd . euclidean_mesh ( grid ) )
64
67
65
68
def transform_to (self , dst_crs ):
66
69
dst_crs = CRS .from_user_input (dst_crs )
@@ -71,9 +74,7 @@ def transform_to(self, dst_crs):
71
74
)
72
75
xy = list (zip (* transformer .transform (self .x , self .y )))
73
76
ids = list (self ._coords .keys ())
74
- self ._coords = {
75
- ids [i ]: coord for i , coord in enumerate (xy )
76
- }
77
+ self ._coords = {ids [i ]: coord for i , coord in enumerate (xy )}
77
78
self ._crs = dst_crs
78
79
79
80
def get_node_index (self , id ):
@@ -115,8 +116,8 @@ def write(self, path, overwrite=False, fmt='gr3'):
115
116
def ascii_string (self , fmt ):
116
117
if fmt .lower () in ['grd' , 'gr3' , 'adcirc' , 'schism' ]:
117
118
return self .grd
118
- if fmt .lower () in ['sms' , '2dm' ]:
119
- return self .sms
119
+ # if fmt.lower() in ['sms', '2dm']:
120
+ # return self.sms
120
121
121
122
@_figure
122
123
def tricontourf (self , axes = None , show = True , figsize = None , ** kwargs ):
0 commit comments