7
7
from shapely .geometry import Point
8
8
import geopandas
9
9
10
- from pygridtools import iotools
11
- from pygridtools import misc
12
10
from pygridtools import validate
13
11
14
12
@@ -93,7 +91,7 @@ def write_cellinp(cell_array, outputfile='cell.inp', mode='w',
93
91
nrows , ncols = cell_array .shape
94
92
95
93
rowfmt = '{0:3d} {1:s}\n '
96
- colfmt = f'{{:0{ _n_digits (ncols )} d}}'
94
+ # colfmt = f'{{:0{_n_digits(ncols)}d}}'
97
95
98
96
if cell_array .shape [1 ] > maxcols :
99
97
first_array = cell_array [:, :maxcols ]
@@ -108,7 +106,7 @@ def write_cellinp(cell_array, outputfile='cell.inp', mode='w',
108
106
109
107
else :
110
108
columns = numpy .arange (1 , maxcols + 1 , dtype = int )
111
- colstr = [list ('{ :04d}'. format ( c ) ) for c in columns ]
109
+ colstr = [list (f' { c :04d} ' ) for c in columns ]
112
110
hundreds = '' .join ([c [1 ] for c in colstr ])
113
111
tens = '' .join ([c [2 ] for c in colstr ])
114
112
ones = '' .join ([c [3 ] for c in colstr ])
@@ -117,19 +115,16 @@ def write_cellinp(cell_array, outputfile='cell.inp', mode='w',
117
115
if writeheader :
118
116
title = 'C -- cell.inp for EFDC model by pygridtools\n '
119
117
outfile .write (title )
120
- outfile .write ('C {} \n ' . format ( hundreds [:ncols ]) )
121
- outfile .write ('C {} \n ' . format ( tens [:ncols ]) )
122
- outfile .write ('C {} \n ' . format ( ones [:ncols ]) )
118
+ outfile .write (f 'C { hundreds [:ncols ]} \n ' )
119
+ outfile .write (f 'C { tens [:ncols ]} \n ' )
120
+ outfile .write (f 'C { ones [:ncols ]} \n ' )
123
121
124
122
for n , row in enumerate (cell_array ):
125
123
row_number = nrows - n
126
124
row_strings = row .astype (str )
127
125
cell_text = '' .join (row_strings .tolist ())
128
- if rowlabels :
129
- rowheader = ''
130
- row_text = rowfmt .format (int (row_number ), cell_text )
131
- else :
132
- row_text = ' {0:s}\n ' .format (cell_text )
126
+
127
+ row_text = rowfmt .format (int (row_number ), cell_text ) if rowlabels else f' { cell_text :s} \n '
133
128
134
129
outfile .write (row_text )
135
130
@@ -153,7 +148,7 @@ def write_gridout_file(xcoords, ycoords, outfile):
153
148
})
154
149
155
150
with Path (outfile ).open ('w' ) as f :
156
- f .write ('## {:d} x {:d}\n ' . format ( nx , ny ) )
151
+ f .write (f '## { nx :d} x { ny :d} \n ' )
157
152
158
153
# XXX: https://github.com/pandas-dev/pandas/issues/21882
159
154
with Path (outfile ).open ('a' ) as f :
@@ -295,8 +290,8 @@ def make_gefdc_cells(node_mask, cell_mask=None, triangles=False):
295
290
if total == bank_cell * shift ** 2 :
296
291
cells [cj , ci ] = land_cell
297
292
298
- nrows = cells .shape [0 ]
299
- ncols = cells .shape [1 ]
293
+ # nrows = cells.shape[0]
294
+ # ncols = cells.shape[1]
300
295
301
296
# nchunks = numpy.ceil(ncols / maxcols)
302
297
# if ncols > maxcols:
0 commit comments