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
0140944b
Commit
0140944b
authored
11 months ago
by
Carsten Hinz
Browse files
Options
Downloads
Patches
Plain Diff
added comment on possible duration of request
parent
d21543ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Creation of first beta release version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/get_sample_data.ipynb
+1
-0
1 addition, 0 deletions
tests/get_sample_data.ipynb
with
1 addition
and
0 deletions
tests/get_sample_data.ipynb
+
1
−
0
View file @
0140944b
...
...
@@ -57,6 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"#this cell can run 30minutes or longer.\n",
"import time\n",
"\n",
"waiting_for_data = True\n",
...
...
%% Cell type:code id: tags:
```
python
from
datetime
import
datetime
#samping monthly or daily
sampling
=
"
monthly
"
start
=
datetime
(
2010
,
1
,
1
)
end
=
datetime
(
2011
,
1
,
1
)
print
(
start
.
date
(),
end
.
date
())
print
(
start
.
isoformat
(),
end
.
isoformat
())
```
%% Cell type:code id: tags:
```
python
import
requests
response
=
requests
.
get
(
"
https://toar-data.fz-juelich.de/api/v2/analysis/statistics/
"
,
params
=
{
"
daterange
"
:
f
"
{
start
.
isoformat
()
}
,
{
end
.
isoformat
()
}
"
,
# 1-year
"
variable_id
"
:
5
,
"
statistics
"
:
"
mean
"
,
"
sampling
"
:
sampling
,
# daily sampling
"
min_data_capture
"
:
0
,
"
limit
"
:
"
None
"
,
# get all timeseries
"
format
"
:
"
by_statistic
"
,
"
metadata_scheme
"
:
"
basic
"
}
)
```
%% Cell type:code id: tags:
```
python
print
(
response
.
status_code
)
status_endpoint
=
response
.
json
()[
"
status
"
]
print
(
status_endpoint
)
```
%% Cell type:code id: tags:
```
python
#this cell can run 30minutes or longer.
import
time
waiting_for_data
=
True
start_time
=
time
.
time
()
while
waiting_for_data
:
time
.
sleep
(
30
)
response
=
requests
.
get
(
status_endpoint
)
waiting_for_data
=
(
response
.
headers
[
"
Content-Type
"
]
==
"
application/json
"
)
response_time
=
time
.
time
()
-
start_time
print
(
response_time
)
```
%% Cell type:code id: tags:
```
python
response
.
headers
[
"
Content-Type
"
],
response
.
headers
[
"
Content-Length
"
]
```
%% Cell type:code id: tags:
```
python
from
pathlib
import
Path
outDir
=
Path
(
"
data
"
)
outDir
.
mkdir
(
parents
=
False
,
exist_ok
=
True
)
fn
=
outDir
/
f
"
{
sampling
}
_
{
start
.
date
()
}
_
{
end
.
date
()
}
.zip
"
with
open
(
fn
,
"
w+b
"
)
as
sample_file
:
sample_file
.
write
(
response
.
content
)
print
(
f
"
Wrote outout to file [path/to/toargridding]/tests/
{
fn
}
"
)
```
...
...
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