Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toargridding
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
esde
toar-public
toargridding
Commits
73d082e9
Commit
73d082e9
authored
10 months ago
by
Carsten Hinz
Browse files
Options
Downloads
Patches
Plain Diff
renamed output file
parent
c82e4bb2
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!11
Creation of first beta release version
,
!10
change in metadata of notebook
,
!9
change in metadata of notebook
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/contributor_metadata.ipynb
+4
-4
4 additions, 4 deletions
examples/contributor_metadata.ipynb
with
4 additions
and
4 deletions
examples/contributor_metadata.ipynb
+
4
−
4
View file @
73d082e9
...
...
@@ -28,7 +28,7 @@
"from toargridding.metadata import Metadata, TimeSample, AnalysisRequestResult, Coordinates\n",
"from toargridding.variables import Coordinate\n",
"\n",
"from toargridding.contributors import contributions
M
anager, contributions_manager_by_name\n",
"from toargridding.contributors import contributions
_m
anager
_by_id
, contributions_manager_by_name\n",
"\n",
"import logging\n",
"from toargridding.defaultLogging import toargridding_defaultLogging\n",
...
...
@@ -68,12 +68,12 @@
"data = analysis_service.get_data(metadata)\n",
"\n",
"# create contributors endpoint and write result to metadata\n",
"contrib = contributions
M
anager(metadata.get_id(), data_download_dir)\n",
"contrib = contributions
_m
anager
_by_id
(metadata.get_id(), data_download_dir)\n",
"contrib.extract_contributors_from_data_frame(data.stations_data)\n",
"metadata.contributors_metadata_field = contrib.setup_contributors_endpoint_for_metadata()\n",
"ds = my_grid.as_xarray(data)\n",
"#store dataset\n",
"ds.to_netcdf(data_download_dir / f\"
curl
+id-file_{metadata.get_id()}_{my_grid.get_id()}.nc\")"
"ds.to_netcdf(data_download_dir / f\"
endpoint
+id-file_{metadata.get_id()}_{my_grid.get_id()}.nc\")"
]
},
{
...
...
@@ -93,7 +93,7 @@
"data = analysis_service.get_data(metadata)\n",
"\n",
"# create contributors endpoint and write result to metadata\n",
"contrib = contributions
M
anager(metadata.get_id(), data_download_dir)\n",
"contrib = contributions
_m
anager
_by_id
(metadata.get_id(), data_download_dir)\n",
"contrib.inline_mode = True\n",
"contrib.extract_contributors_from_data_frame(data.stations_data)\n",
"metadata.contributors_metadata_field = contrib.setup_contributors_endpoint_for_metadata()\n",
...
...
%% Cell type:markdown id: tags:
### Get Dataset from request
%% Cell type:code id: tags:
```
python
from
datetime
import
datetime
as
dt
from
pathlib
import
Path
import
pandas
as
pd
import
numpy
as
np
from
toargridding.grids
import
RegularGrid
from
toargridding.toar_rest_client
import
(
AnalysisServiceDownload
,
STATION_LAT
,
STATION_LON
,
)
from
toargridding.metadata
import
Metadata
,
TimeSample
,
AnalysisRequestResult
,
Coordinates
from
toargridding.variables
import
Coordinate
from
toargridding.contributors
import
contributions
M
anager
,
contributions_manager_by_name
from
toargridding.contributors
import
contributions
_m
anager
_by_id
,
contributions_manager_by_name
import
logging
from
toargridding.defaultLogging
import
toargridding_defaultLogging
#setup of logging
logger
=
toargridding_defaultLogging
()
logger
.
addShellLogger
(
logging
.
DEBUG
)
logger
.
logExceptions
()
endpoint
=
"
https://toar-data.fz-juelich.de/api/v2/analysis/statistics/
"
#starts in directory [path/to/toargridding]/tests
#maybe adopt the toargridding_base_path for your machine.
toargridding_base_path
=
Path
(
"
.
"
)
cache_dir
=
toargridding_base_path
/
"
cache
"
data_download_dir
=
toargridding_base_path
/
"
results
"
analysis_service
=
AnalysisServiceDownload
(
endpoint
,
cache_dir
,
data_download_dir
,
use_downloaded
=
True
)
my_grid
=
RegularGrid
(
1.9
,
2.5
)
time
=
TimeSample
(
dt
(
2016
,
1
,
1
),
dt
(
2016
,
2
,
28
),
"
daily
"
)
metadata
=
Metadata
.
construct
(
"
mole_fraction_of_ozone_in_air
"
,
time
,
"
mean
"
)
```
%% Cell type:markdown id: tags:
# Contributors as dedicated file
%% Cell type:code id: tags:
```
python
# this cell can runs longer than 30minutes
data
=
analysis_service
.
get_data
(
metadata
)
# create contributors endpoint and write result to metadata
contrib
=
contributions
M
anager
(
metadata
.
get_id
(),
data_download_dir
)
contrib
=
contributions
_m
anager
_by_id
(
metadata
.
get_id
(),
data_download_dir
)
contrib
.
extract_contributors_from_data_frame
(
data
.
stations_data
)
metadata
.
contributors_metadata_field
=
contrib
.
setup_contributors_endpoint_for_metadata
()
ds
=
my_grid
.
as_xarray
(
data
)
#store dataset
ds
.
to_netcdf
(
data_download_dir
/
f
"
curl
+id-file_
{
metadata
.
get_id
()
}
_
{
my_grid
.
get_id
()
}
.nc
"
)
ds
.
to_netcdf
(
data_download_dir
/
f
"
endpoint
+id-file_
{
metadata
.
get_id
()
}
_
{
my_grid
.
get_id
()
}
.nc
"
)
```
%% Cell type:markdown id: tags:
# Contributors as single line request
%% Cell type:code id: tags:
```
python
# this cell can runs longer than 30minutes
data
=
analysis_service
.
get_data
(
metadata
)
# create contributors endpoint and write result to metadata
contrib
=
contributions
M
anager
(
metadata
.
get_id
(),
data_download_dir
)
contrib
=
contributions
_m
anager
_by_id
(
metadata
.
get_id
(),
data_download_dir
)
contrib
.
inline_mode
=
True
contrib
.
extract_contributors_from_data_frame
(
data
.
stations_data
)
metadata
.
contributors_metadata_field
=
contrib
.
setup_contributors_endpoint_for_metadata
()
ds
=
my_grid
.
as_xarray
(
data
)
#store dataset
ds
.
to_netcdf
(
data_download_dir
/
f
"
request_in_field_
{
metadata
.
get_id
()
}
_
{
my_grid
.
get_id
()
}
.nc
"
)
```
%% Cell type:markdown id: tags:
# Contributors by name within field
%% Cell type:code id: tags:
```
python
# this cell can runs longer than 30minutes
data
=
analysis_service
.
get_data
(
metadata
)
# create contributors endpoint and write result to metadata
contrib
=
contributions_manager_by_name
(
metadata
.
get_id
(),
data_download_dir
)
contrib
.
inline_mode
=
True
contrib
.
extract_contributors_from_data_frame
(
data
.
stations_data
)
metadata
.
contributors_metadata_field
=
contrib
.
setup_contributors_endpoint_for_metadata
()
ds
=
my_grid
.
as_xarray
(
data
)
#store dataset
ds
.
to_netcdf
(
data_download_dir
/
f
"
by_name_
{
metadata
.
get_id
()
}
_
{
my_grid
.
get_id
()
}
.nc
"
)
```
...
...
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