Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Runoff_prediction
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mazzolini Marco
Runoff_prediction
Commits
1fd397f2
Commit
1fd397f2
authored
3 years ago
by
Marco Mazzolini
Browse files
Options
Downloads
Patches
Plain Diff
Update create_daily_csv fot getting all the pixels
parent
ecadb029
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
create_daily_csv.py
+5
-4
5 additions, 4 deletions
create_daily_csv.py
with
5 additions
and
4 deletions
create_daily_csv.py
+
5
−
4
View file @
1fd397f2
...
...
@@ -91,7 +91,7 @@ def readnetcdf_in_shp(nc_fileName, shp_fileName, res=5500, plot=False):
ds
=
ds
.
dropna
(
dim
=
'
x
'
,
how
=
'
all
'
)
ds
=
ds
.
dropna
(
dim
=
'
y
'
,
how
=
'
all
'
)
counter
=
0
# Plot the era5 gridbox and the shapefile if plot=True
if
plot
:
for
x
in
ds
.
x
.
values
:
...
...
@@ -103,10 +103,11 @@ def readnetcdf_in_shp(nc_fileName, shp_fileName, res=5500, plot=False):
if
(
k
!=
'
Lambert_Conformal
'
):
if
not
(
ds
[
k
].
loc
[
dict
(
x
=
x
,
y
=
y
)].
isnull
().
all
()):
plt
.
plot
(
x
,
y
,
marker
=
'
o
'
,
color
=
'
red
'
)
counter
=
counter
+
1
shp_x
,
shp_y
=
shp_reproj
.
loc
[
0
,
'
geometry
'
].
exterior
.
xy
plt
.
plot
(
shp_x
,
shp_y
,
color
=
'
black
'
)
plt
.
axis
(
'
equal
'
)
print
(
f
'
n of pixels
{
counter
}
'
)
return
ds
...
...
@@ -115,14 +116,14 @@ def xarray2df(xa, varnamedest,varnameor=False):
df
=
{}
for
i
in
range
(
xa
.
y
.
size
):
for
j
in
range
(
xa
.
x
.
size
):
df
[
f
'
{
varnamedest
}{
i
*
xa
.
y
.
size
+
j
}
'
]
=
xa
.
isel
(
y
=
i
,
x
=
j
).
to_dataframe
().
iloc
[:,
2
]
df
[
f
'
{
varnamedest
}{
i
*
xa
.
x
.
size
+
j
}
'
]
=
xa
.
isel
(
y
=
i
,
x
=
j
).
to_dataframe
().
iloc
[:,
2
]
#pdb.set_trace()
else
:
df
=
{}
for
i
in
range
(
xa
.
y
.
size
):
for
j
in
range
(
xa
.
x
.
size
):
df
[
f
'
{
varnamedest
}{
i
*
xa
.
y
.
size
+
j
}
'
]
=
xa
.
isel
(
y
=
i
,
x
=
j
).
to_dataframe
().
loc
[:,
varnameor
]
df
[
f
'
{
varnamedest
}{
i
*
xa
.
x
.
size
+
j
}
'
]
=
xa
.
isel
(
y
=
i
,
x
=
j
).
to_dataframe
().
loc
[:,
varnameor
]
#pdb.set_trace()
frame
=
pd
.
DataFrame
(
df
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment