Skip to content

Commit

Permalink
#80 change grid production for multicore mode
Browse files Browse the repository at this point in the history
  • Loading branch information
demanasta committed Jul 29, 2024
1 parent 8c46b25 commit a20929e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
12 changes: 6 additions & 6 deletions plot/default-param
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ PAPER_SIZE="30cx30c" # width x height

# //////////////////////////////////////////////////////////////////////////////
# Set default REGION
west=-62.5
east=-50
south=-40
north=-29.5
projscale=6000000
west=19
east=43
south=34
north=45
projscale=8000000
frame=2

# length of plot scale (Km)
Expand All @@ -37,7 +37,7 @@ VSC=0.05
strscmagn=100
STRSC=.0080
ROTSC=.65
ROT_wedge_mag=0.5 #(deg/My)
ROT_wedge_mag=1 #(deg/My)
# strsclon=20.4 #delete
# strsclat=36.3 #delete

Expand Down
18 changes: 11 additions & 7 deletions pystrain/pystrain/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ class Grid:
"""

def split2four(self):
if self.xpts % 2 !=0:
self.xpts += 1
if self.ypts % 2 !=0:
self.ypts += 1
x2 = self.x_min + (self.xpts/2)*self.x_step
y2 = self.y_min + (self.ypts/2)*self.y_step
g1 = Grid(self.x_min, x2, self.x_step, self.y_min, y2, self.y_step)
g2 = Grid(x2, self.x_max, self.x_step, self.y_min, y2, self.y_step)
g2 = Grid(x2, self.x_max, self.x_step, self.y_min, y2, self.y_step)
g3 = Grid(self.x_min, x2, self.x_step, y2, self.y_max, self.y_step)
g4 = Grid(x2, self.x_max, self.x_step, y2, self.y_max, self.y_step)
#print('--> /grd1/: X:{:}/{:}/{:} Y:{:}/{:}/{:}'.format(g1.x_min, g1.x_max, g1.x_step, g1.y_min, g1.y_max, g1.y_step))
Expand Down Expand Up @@ -72,8 +76,8 @@ def __init__(self, x_min, x_max, x_step, y_min, y_max, y_step, strict_upper_limi
each of the axis (aka x and y), the function will perform a
computation of the type:
xpts = int(floor((x_max-x_min) / float(x_step)))
This is quite accurate, but due to roundoff errors, it may
happen that the quantity x_min + xpts * x_step is just a bit
This is quite accurate, but due to roundoff errors, it may
happen that the quantity x_min + xpts * x_step is just a bit
larger than x_max.
If the user definitely wants the formula:
x_min + self.xpts * x_step <= x_max to hold, then the option
Expand Down Expand Up @@ -117,7 +121,7 @@ def __iter__(self):

def xidx2xval(self, idx):
"""Index to value for x-axis.
Given an index (on x-axis), return the value at the centre of this
cell. The index represents the number of a cell (starting from
zero).
Expand All @@ -127,10 +131,10 @@ def xidx2xval(self, idx):
"""
assert idx >= 0 and idx < self.xpts
return self.x_min + self.x_step/2e0 + self.x_step*float(idx)

def yidx2yval(self, idx):
"""Index to value for y-axis.
Given an index (on y-axis), return the value at the centre of this
cell. The index represents the number of a cell (starting from
zero).
Expand Down Expand Up @@ -200,7 +204,7 @@ def generate_grid(sta_lst, x_step, y_step, sta_lst_to_deg=False):
the y-axis)
Todo:
The lines
The lines
assert divmod(y_max-y_min, y_step)[1] == 0e0 and
assert divmod(x_max-x_min, x_step)[1] == 0e0
may throw dues to rounding errors; how can i fix that?
Expand Down

0 comments on commit a20929e

Please sign in to comment.