Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Ostberg
WM_LPJmL_indicators
Commits
722d0401
Commit
722d0401
authored
Dec 13, 2021
by
Sebastian Ostberg
Browse files
add _Encoding attribute to NetCDF files to help with reading character arrays in Python
parent
7de44b3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
risk_yield_loss.R
View file @
722d0401
...
...
@@ -857,7 +857,15 @@ nc2 <- nc_create(
risk_category_var
)
)
# Set "_Encoding" attribute for character variables to ensure correct reading in
# Python
# First file
ncatt_put
(
nc
,
crop_var
,
"_Encoding"
,
"utf-8"
)
ncatt_put
(
nc
,
irrigation_var
,
"_Encoding"
,
"utf-8"
)
# Second file
ncatt_put
(
nc2
,
crop_var
,
"_Encoding"
,
"utf-8"
)
ncatt_put
(
nc2
,
irrigation_var
,
"_Encoding"
,
"utf-8"
)
ncatt_put
(
nc2
,
risk_category_var
,
"_Encoding"
,
"utf-8"
)
# Write name attributes
# First file
ncvar_put
(
nc
,
crop_var
,
dimnames
(
yield_loss_risk
)[[
3
]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment