-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read dataset #3
Open
crdanielbusch
wants to merge
85
commits into
main
Choose a base branch
from
read-dataset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Read dataset #3
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
50142e9
outline steps to read data
crdanielbusch dce5549
read first domain
crdanielbusch 6be433d
read emissions from crops [skip ci]
crdanielbusch 5b28d9d
all land use domains [skip ci]
crdanielbusch 13d03c4
fix country mapping [skip ci]
crdanielbusch 76f9e52
all data in if, pm2 format still fails [skip ci]
crdanielbusch 8ae9ca1
clean up, refactor
crdanielbusch 18ce100
[DATALAD] Recorded changes
crdanielbusch 2fbdfbf
[DATALAD RUNCMD] poetry run python3 scripts/read_all_doma...
crdanielbusch e70f4ea
[DATALAD] Recorded changes
crdanielbusch af533a5
[DATALAD RUNCMD] poetry run python3 scripts/read_all_doma...
crdanielbusch 0b3d4c4
imports
crdanielbusch 340152f
integration test for read script
crdanielbusch 854a0e1
clean up
crdanielbusch f3d6e19
integration test for download and read
crdanielbusch a7f6c6b
mypy
crdanielbusch a6f197f
changelog
crdanielbusch 86885b5
licence for numbagg
crdanielbusch 3fab64e
licence
crdanielbusch 65d79de
increase sleep time to load page
crdanielbusch cbe54f5
country definitions
crdanielbusch 162b81a
[DATALAD] Recorded changes
crdanielbusch e33f4ee
[DATALAD] Recorded changes
crdanielbusch e1f5969
[DATALAD] Recorded changes
crdanielbusch 3443f72
[DATALAD] Recorded changes
crdanielbusch f3729ea
[DATALAD] Recorded changes
crdanielbusch 301d48d
[DATALAD] Recorded changes
crdanielbusch c893e40
[DATALAD] Recorded changes
crdanielbusch f16249a
[DATALAD RUNCMD] Read data set
crdanielbusch 3e3f054
[DATALAD] Recorded changes
crdanielbusch cb8acaa
[DATALAD RUNCMD] Read data set
crdanielbusch 4ba4d3d
[DATALAD] removed content
crdanielbusch 9a4aabe
[DATALAD] Recorded changes
crdanielbusch e7977d0
[DATALAD] Recorded changes
crdanielbusch 6d95ab5
[DATALAD] Recorded changes
crdanielbusch 54875d3
[DATALAD] Recorded changes
crdanielbusch 34e6ee4
[DATALAD] removed content
crdanielbusch 9a35563
[DATALAD] removed content
crdanielbusch e885693
[DATALAD] removed content
crdanielbusch b29152b
[DATALAD] Recorded changes
crdanielbusch 05e714b
[DATALAD] Recorded changes
crdanielbusch f1fbcad
[DATALAD] removed content
crdanielbusch 4845631
[DATALAD] Recorded changes
crdanielbusch 803456e
[DATALAD] removed content
crdanielbusch 21ee486
[DATALAD] removed content
crdanielbusch 9dc94b0
[DATALAD] Recorded changes
crdanielbusch 76faa95
[DATALAD] Recorded changes
crdanielbusch b9e21eb
[DATALAD] Recorded changes
crdanielbusch 9207140
[DATALAD] Recorded changes
crdanielbusch 094dfa5
[DATALAD] Recorded changes
crdanielbusch 8a54f40
[DATALAD] Recorded changes
crdanielbusch 9cfa7fe
[DATALAD] removed content
crdanielbusch 0d19603
[DATALAD] removed content
crdanielbusch f35826d
[DATALAD] Recorded changes
crdanielbusch 7b8e334
[DATALAD RUNCMD] python3 scripts/download_all_domains.py
crdanielbusch 849d722
[DATALAD] Recorded changes
crdanielbusch 3223f15
[DATALAD] removed content
crdanielbusch cf47c50
[DATALAD] Recorded changes
crdanielbusch 6fb9b7d
[DATALAD RUNCMD] python3 scripts/download_all_domains.py
crdanielbusch a05626e
[DATALAD] Recorded changes
crdanielbusch 2c16c3f
[DATALAD] Recorded changes
crdanielbusch 45d9fa6
[DATALAD] Recorded changes
crdanielbusch e9bcfd0
[DATALAD] removed content
crdanielbusch 7bafca5
[DATALAD] removed content
crdanielbusch 8808c27
[DATALAD] Recorded changes
crdanielbusch b144624
[DATALAD RUNCMD] python3 scripts/download_all_domains.py
crdanielbusch 585f542
[DATALAD] Recorded changes
crdanielbusch 449fe13
[DATALAD] removed content
crdanielbusch 9f0d912
[DATALAD] Recorded changes
crdanielbusch cce65fb
[DATALAD RUNCMD] python3 scripts/download_all_domains.py
crdanielbusch 581b921
[DATALAD] Recorded changes
crdanielbusch 95371de
[DATALAD] Recorded changes
crdanielbusch 2c7ad7e
Merge remote-tracking branch 'refs/remotes/gin/doit' into doit
crdanielbusch 342fc8a
[DATALAD] Recorded changes
crdanielbusch 6c17a92
[DATALAD] Recorded changes
crdanielbusch 22f85bf
[DATALAD] Recorded changes
crdanielbusch 5338838
[DATALAD] Recorded changes
crdanielbusch 46e01ee
[DATALAD] Recorded changes
crdanielbusch be1d3fc
[DATALAD] Recorded changes
crdanielbusch 0ab94c8
[DATALAD] Recorded changes
crdanielbusch 6a25dc1
[DATALAD] Recorded changes
crdanielbusch cf06ff0
[DATALAD] Recorded changes
crdanielbusch 41a762b
[DATALAD] Recorded changes
crdanielbusch 239167b
Merge pull request #5 from primap-community/doit
crdanielbusch f92d041
Merge remote-tracking branch 'refs/remotes/github/main' into read-dat…
crdanielbusch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a scripts that converts the downloaded data into IF and primap2 native format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Define tasks to download and read the FAO data set. | ||
""" | ||
import datalad.api | ||
|
||
|
||
def task_download(): | ||
""" | ||
Download latest data | ||
""" | ||
|
||
def datalad_run_download(): | ||
datalad.api.run( | ||
cmd="python3 scripts/download_all_domains.py", | ||
outputs="downloaded_data", | ||
) | ||
|
||
return {"actions": [datalad_run_download]} | ||
|
||
|
||
def task_read(): | ||
""" | ||
read data set | ||
""" | ||
|
||
def read_dataset(save_path, run_id): | ||
print(f"Reading dataset for {save_path=} and {run_id=}") | ||
cmd = ( | ||
f"python3 scripts/read_data_set.py " | ||
f"--save_path {save_path} --run_id {run_id}" | ||
) | ||
|
||
datalad.api.run( | ||
cmd=cmd, | ||
message="Read data set", | ||
outputs=f"{save_path}", | ||
) | ||
|
||
return { | ||
"actions": [read_dataset], | ||
"params": [ | ||
{ | ||
"name": "save_path", | ||
"short": "s", | ||
"long": "save_path", | ||
"default": "extracted_data", | ||
"help": "Path to save the data.", | ||
}, | ||
{ | ||
"name": "run_id", | ||
"long": "run_id", | ||
"short": "r", | ||
"default": "2024", | ||
"help": "Run identifier.", | ||
}, | ||
], | ||
"verbosity": 2, | ||
} |
1 change: 1 addition & 0 deletions
1
extracted_data/v2024-11-14/FAOSTAT_Agrifood_system_emissions_v2024-11-14.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.git/annex/objects/fQ/4m/MD5E-s4236841--55a238326c11e125114380c4502d7cf4.csv/MD5E-s4236841--55a238326c11e125114380c4502d7cf4.csv |
1 change: 1 addition & 0 deletions
1
extracted_data/v2024-11-14/FAOSTAT_Agrifood_system_emissions_v2024-11-14.nc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.git/annex/objects/FX/kw/MD5E-s2607829--fa792e6284b6dc663c97a0c587210e07.nc/MD5E-s2607829--fa792e6284b6dc663c97a0c587210e07.nc |
22 changes: 22 additions & 0 deletions
22
extracted_data/v2024-11-14/FAOSTAT_Agrifood_system_emissions_v2024-11-14.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
attrs: | ||
references: https://www.fao.org/faostat | ||
rights: Creative Commons Attribution-4.0 International licence (CC BY 4.0) | ||
contact: [email protected] | ||
title: Agrifood systems emissions | ||
comment: Published by Food and Agriculture Organization of the United Nations (FAO), | ||
converted to PRIMAP2 format by Daniel Busch | ||
institution: Food and Agriculture Organization of the United Nations | ||
area: area (ISO3) | ||
cat: category (FAOSTAT) | ||
scen: scenario (FAO) | ||
time_format: '%Y' | ||
dimensions: | ||
'*': | ||
- time | ||
- source | ||
- category (FAOSTAT) | ||
- area (ISO3) | ||
- scenario (FAO) | ||
- entity | ||
- unit | ||
data_file: FAOSTAT_Agrifood_system_emissions_v2024-11-14.csv |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Read the latest release of all available domains.""" | ||
|
||
from faostat_data_primap.read import ( | ||
read_latest_data, | ||
) | ||
|
||
if __name__ == "__main__": | ||
read_latest_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Read selected domains and versions.""" | ||
from pathlib import Path | ||
|
||
import click | ||
|
||
from faostat_data_primap.helper.definitions import domains_and_releases_to_read | ||
from faostat_data_primap.helper.paths import ( | ||
extracted_data_path, | ||
) | ||
from faostat_data_primap.read import ( | ||
read_data, | ||
) | ||
|
||
|
||
@click.command() | ||
@click.option("--run_id", default="2024", help="Configuration to run") | ||
@click.option("--save_path", default=None, help="Where to save data in root directory.") | ||
def run(run_id, save_path): | ||
"""Prepare and run read data function""" | ||
if not save_path: | ||
save_path = extracted_data_path | ||
else: | ||
save_path = Path(save_path) | ||
read_data( | ||
domains_and_releases_to_read=domains_and_releases_to_read[run_id], | ||
save_path=save_path, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More general comment: I think it would e good to have an option to re-read older data as well,e.g. if we read additional data or variables.