xcodex


Namexcodex JSON
Version 0.0.6 PyPI version JSON
download
home_page
SummaryThis package will download and extract daily data of XCO2 from the NASA Goddard Earth Sciences (GES)
upload_time2023-06-07 12:37:37
maintainer
docs_urlNone
authorhenriquefl24@git
requires_python>=3.8
license
keywords python nasa ges disc xco2 daily oco-2 jupyter notebook xcodex
VCS
bugtrack_url
requirements pandas numpy netCDF4 jupyter requests setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![CABEƇALHO](https://i.imgur.com/Pq8uUM3.jpg)

### *Please, cite this package as:*

Laurito, H., La Scala, N., Rolim, G. S., 2023. Extracting XCO2-NASA Daily data with XCODEX:
A Python package designed for data extraction and structuration. Jaboticabal, SP, BR, (...)

# **Welcome to XCODEX - XCO2 Daily EXtractor**

Hi there! My name is Henrique.

The creation of this Python package was intended to create a simple solution for extracting daily data from XCO2 retrieved from the GES DISC platform.

I will attach the links containing the GitHub profile of the researchers who helped me in the development of this package along with graphical visualization of the data and the citation of the OCO-2 project.

I hope it's useful to you. **Long live science!**

## *Installing the package*

To install the package, use the command:
```angular2html
pip install xcodex
```
## *Using XCODEX*

There's the possibility to download the .nc4 files directly here:
```angular2html
# Setting historical serie

from xcodex.main import download_file

start_date = "1st of January, 2022"
end_date = "31st of January, 2022"

# Downloading .nc4 files
download_file(start_date, end_date) 
```
__Note that ERROR 401 usually is related to unavailable data.__

Once the download is completed, a ``downloaded_data`` folder will be created in your current path.
<br>After that, let's use ``xco2_extract()`` to retrieve XCO2 data from the .nc4 files:
<br> 

```angular2html
from glob import glob
from os.path import join
from os import getcwd

# Selecting the folder with .nc4 files

arquive_folder = glob(join(getcwd(), "downloaded_data", "*.nc4")) 

# Setting desired locations to build a time series XCO2 data

locations = dict(Mauna_loa=[19.479488, -155.602829],
                 New_York=[40.712776, -74.005974],
                 Paris=[48.856613, 2.352222])

from xcodex.main import xco2_extract

df = xco2_extract(path=arquive_folder,
                  start=start_date,
                  end=end_date,
                  missing_data=False,
                  **locations); df # Extracting XCO2
      
```
Note1: The location used in this example was Mauna Loa, New York and Paris. Any location can be used<br>
as long the format "Location[lat, lon]" is respected. The values of <br>
latitude and longitude must be in decimal degrees.

for more information, please execute the command: <br>

````angular2html
help(xco2_extractor)
````

Finally, you will have a `pandas.Dataframe` as result. Now it's up to you how you'll <br>
handle it. I recomend checking the `Github profiles` below for data visualization.

### Data visualization
Here we can plot in a map the locations:
````angular2html
## set mapbox access token

import plotly.express as px
import plotly.graph_objs as go

px.set_mapbox_access_token('pk.eyJ1Ijoic2FnYXJsaW1idTAiLCJhIjoiY2t2MXhhMm5mNnE5ajJ3dDl2eDZvNTM2NiJ9.1bwmb8HPgFZWwR8kcO5rOA')

# Plotly configs

fig= px.scatter_mapbox(df,
                              lat= 'lat',
                              lon= 'lon',
                              color= 'xco2',
                              zoom= .85,
                              width=960,
                              height=540,
                              size_max=10,
                              hover_name='city',
                              color_continuous_scale=px.colors.cyclical.IceFire)

fig.update_layout(mapbox_style="dark") #"open-street-map"


layout = go.Layout(margin=go.layout.Margin(
    l=0,
    r=0,
    b=0,
    t=0))


fig.update_layout(layout,
                  autosize=False,
                  height=540,
                  width=960,
                  hovermode="closest")

# Saving the output image

#fig.write_html('xcodex_map.html')
#fig.write_image("xcodex_map.png", scale=2)

fig.show()
````
And finally a way to observe the XCO2 behavior during the time serie:
````angular2html
# Showing XCO2 behavior in time serie

import matplotlib.pyplot as plt
import seaborn as sns

plt.figure(figsize=(10,5))

sns.set_theme(font_scale=1, style="white")

sns.lineplot(data=df,
             x="jd",
             y='xco2',
             hue='city',
             errorbar=('ci',0),
             palette="tab10")

plt.xlabel("")
plt.ylabel("XCO2 (ppm)")

plt.xlim(min(df.jd), max(df.jd))
plt.ylim(min(df.xco2), max(df.xco2))

sns.despine(right=False,
            top=False)

plt.legend(ncol=3)

plt.tight_layout()

#plt.savefig("xcodex_locations.png", dpi=300)

plt.show()
````
### *GitHub profiles*:

https://github.com/GlaucoRolim (Co-author) <br>
https://github.com/kyuenjpl/ARSET_XCO2 <br>
https://github.com/sagarlimbu0/OCO2-OCO3

### **Data source citation**:

Brad Weir, Lesley Ott and OCO-2 Science Team (2022), OCO-2 GEOS Level 3 daily,
0.5x0.625 assimilated CO2 V10r, Greenbelt, MD, USA, Goddard Earth Sciences Data
and Information Services Center (GES DISC), Accessed: 10/31/2022,
doi: 10.5067/Y9M4NM9MPCGH

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "xcodex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "python,NASA,GES DISC,XCO2,daily,OCO-2,jupyter notebook,xcodex",
    "author": "henriquefl24@git",
    "author_email": "Henrique Fontellas Laurito <henrique.f.laurito@unesp.br>",
    "download_url": "https://files.pythonhosted.org/packages/b4/f6/a375b9fc9175096beace20842207dcca6849358c868cef79eb5edca27279/xcodex-0.0.6.tar.gz",
    "platform": null,
    "description": "![CABE\u00c7ALHO](https://i.imgur.com/Pq8uUM3.jpg)\n\n### *Please, cite this package as:*\n\nLaurito, H., La Scala, N., Rolim, G. S., 2023. Extracting XCO2-NASA Daily data with XCODEX:\nA Python package designed for data extraction and structuration. Jaboticabal, SP, BR, (...)\n\n# **Welcome to XCODEX - XCO2 Daily EXtractor**\n\nHi there! My name is Henrique.\n\nThe creation of this Python package was intended to create a simple solution for extracting daily data from XCO2 retrieved from the GES DISC platform.\n\nI will attach the links containing the GitHub profile of the researchers who helped me in the development of this package along with graphical visualization of the data and the citation of the OCO-2 project.\n\nI hope it's useful to you. **Long live science!**\n\n## *Installing the package*\n\nTo install the package, use the command:\n```angular2html\npip install xcodex\n```\n## *Using XCODEX*\n\nThere's the possibility to download the .nc4 files directly here:\n```angular2html\n# Setting historical serie\n\nfrom xcodex.main import download_file\n\nstart_date = \"1st of January, 2022\"\nend_date = \"31st of January, 2022\"\n\n# Downloading .nc4 files\ndownload_file(start_date, end_date) \n```\n__Note that ERROR 401 usually is related to unavailable data.__\n\nOnce the download is completed, a ``downloaded_data`` folder will be created in your current path.\n<br>After that, let's use ``xco2_extract()`` to retrieve XCO2 data from the .nc4 files:\n<br> \n\n```angular2html\nfrom glob import glob\nfrom os.path import join\nfrom os import getcwd\n\n# Selecting the folder with .nc4 files\n\narquive_folder = glob(join(getcwd(), \"downloaded_data\", \"*.nc4\")) \n\n# Setting desired locations to build a time series XCO2 data\n\nlocations = dict(Mauna_loa=[19.479488, -155.602829],\n                 New_York=[40.712776, -74.005974],\n                 Paris=[48.856613, 2.352222])\n\nfrom xcodex.main import xco2_extract\n\ndf = xco2_extract(path=arquive_folder,\n                  start=start_date,\n                  end=end_date,\n                  missing_data=False,\n                  **locations); df # Extracting XCO2\n      \n```\nNote1: The location used in this example was Mauna Loa, New York and Paris. Any location can be used<br>\nas long the format \"Location[lat, lon]\" is respected. The values of <br>\nlatitude and longitude must be in decimal degrees.\n\nfor more information, please execute the command: <br>\n\n````angular2html\nhelp(xco2_extractor)\n````\n\nFinally, you will have a `pandas.Dataframe` as result. Now it's up to you how you'll <br>\nhandle it. I recomend checking the `Github profiles` below for data visualization.\n\n### Data visualization\nHere we can plot in a map the locations:\n````angular2html\n## set mapbox access token\n\nimport plotly.express as px\nimport plotly.graph_objs as go\n\npx.set_mapbox_access_token('pk.eyJ1Ijoic2FnYXJsaW1idTAiLCJhIjoiY2t2MXhhMm5mNnE5ajJ3dDl2eDZvNTM2NiJ9.1bwmb8HPgFZWwR8kcO5rOA')\n\n# Plotly configs\n\nfig= px.scatter_mapbox(df,\n                              lat= 'lat',\n                              lon= 'lon',\n                              color= 'xco2',\n                              zoom= .85,\n                              width=960,\n                              height=540,\n                              size_max=10,\n                              hover_name='city',\n                              color_continuous_scale=px.colors.cyclical.IceFire)\n\nfig.update_layout(mapbox_style=\"dark\") #\"open-street-map\"\n\n\nlayout = go.Layout(margin=go.layout.Margin(\n    l=0,\n    r=0,\n    b=0,\n    t=0))\n\n\nfig.update_layout(layout,\n                  autosize=False,\n                  height=540,\n                  width=960,\n                  hovermode=\"closest\")\n\n# Saving the output image\n\n#fig.write_html('xcodex_map.html')\n#fig.write_image(\"xcodex_map.png\", scale=2)\n\nfig.show()\n````\nAnd finally a way to observe the XCO2 behavior during the time serie:\n````angular2html\n# Showing XCO2 behavior in time serie\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nplt.figure(figsize=(10,5))\n\nsns.set_theme(font_scale=1, style=\"white\")\n\nsns.lineplot(data=df,\n             x=\"jd\",\n             y='xco2',\n             hue='city',\n             errorbar=('ci',0),\n             palette=\"tab10\")\n\nplt.xlabel(\"\")\nplt.ylabel(\"XCO2 (ppm)\")\n\nplt.xlim(min(df.jd), max(df.jd))\nplt.ylim(min(df.xco2), max(df.xco2))\n\nsns.despine(right=False,\n            top=False)\n\nplt.legend(ncol=3)\n\nplt.tight_layout()\n\n#plt.savefig(\"xcodex_locations.png\", dpi=300)\n\nplt.show()\n````\n### *GitHub profiles*:\n\nhttps://github.com/GlaucoRolim (Co-author) <br>\nhttps://github.com/kyuenjpl/ARSET_XCO2 <br>\nhttps://github.com/sagarlimbu0/OCO2-OCO3\n\n### **Data source citation**:\n\nBrad Weir, Lesley Ott and OCO-2 Science Team (2022), OCO-2 GEOS Level 3 daily,\n0.5x0.625 assimilated CO2 V10r, Greenbelt, MD, USA, Goddard Earth Sciences Data\nand Information Services Center (GES DISC), Accessed: 10/31/2022,\ndoi: 10.5067/Y9M4NM9MPCGH\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This package will download and extract daily data of XCO2 from the NASA Goddard Earth Sciences (GES)",
    "version": "0.0.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/henriquefl24/xcodex/issues",
        "Homepage": "https://github.com/henriquefl24/xcodex"
    },
    "split_keywords": [
        "python",
        "nasa",
        "ges disc",
        "xco2",
        "daily",
        "oco-2",
        "jupyter notebook",
        "xcodex"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7aa0b120da659b41d86bb7e4569b667b6aeccf0a493bbab1d0b4bada63c936d",
                "md5": "db1a4914c2b3d8ca4c467e08c00f36cf",
                "sha256": "3e4c78ed4bccebd24ad054b868ef70d61adbf3da7b6b611ee952cafb03e8745f"
            },
            "downloads": -1,
            "filename": "xcodex-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db1a4914c2b3d8ca4c467e08c00f36cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12561,
            "upload_time": "2023-06-07T12:35:06",
            "upload_time_iso_8601": "2023-06-07T12:35:06.958229Z",
            "url": "https://files.pythonhosted.org/packages/a7/aa/0b120da659b41d86bb7e4569b667b6aeccf0a493bbab1d0b4bada63c936d/xcodex-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4f6a375b9fc9175096beace20842207dcca6849358c868cef79eb5edca27279",
                "md5": "ca0b27308f271accc8cc62f75f96393f",
                "sha256": "3f846e6ad1efa45d374706e59167a30dadf00c4dd664bf0d65f53a403eab9b63"
            },
            "downloads": -1,
            "filename": "xcodex-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ca0b27308f271accc8cc62f75f96393f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13170,
            "upload_time": "2023-06-07T12:37:37",
            "upload_time_iso_8601": "2023-06-07T12:37:37.040147Z",
            "url": "https://files.pythonhosted.org/packages/b4/f6/a375b9fc9175096beace20842207dcca6849358c868cef79eb5edca27279/xcodex-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-07 12:37:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "henriquefl24",
    "github_project": "xcodex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.24.3"
                ]
            ]
        },
        {
            "name": "netCDF4",
            "specs": [
                [
                    "==",
                    "1.6.3"
                ]
            ]
        },
        {
            "name": "jupyter",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "~=",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "67.8.0"
                ]
            ]
        }
    ],
    "lcname": "xcodex"
}
        
Elapsed time: 0.08069s