Skip to content
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

add support of PDEF in ctl #7

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


## 1. Introduction
The Grid Analysis and Display System ([GrADS](http://cola.gmu.edu/grads/) or [OpenGrADS](http://www.opengrads.org/)) is a widely used software for easy access, manipulation, and visualization of earth science data. It uses a descriptor (or control) file with a suffix `.ctl` to describe a raw binary 4D dataset. The `ctl` file is similar to the header information of a [NetCDF](https://www.unidata.ucar.edu/software/netcdf/docs/file_structure_and_performance.html) file, containing all the information about dimensions, attributes, and variables except for the variable data.
The Grid Analysis and Display System ([GrADS](http://cola.gmu.edu/grads/) or [OpenGrADS](http://www.opengrads.org/)) is a widely used software for easy access, manipulation, and visualization of earth science data. It uses a [descriptor (or control) file with a suffix `.ctl`](http://cola.gmu.edu/grads/gadoc/descriptorfile.html) to describe a raw binary 4D dataset. The `ctl` file is similar to the header information of a [NetCDF](https://www.unidata.ucar.edu/software/netcdf/docs/file_structure_and_performance.html) file, containing all the information about dimensions, attributes, and variables except for the variable data.

This python package [`xgrads`](https://github.com/miniufo/xgrads) is designed for parse and read the `.ctl` file commonly used by [GrADS](http://cola.gmu.edu/grads/). Right now it can parse various kinds of `.ctl` files. However, only the commonly used raw binary 4D datasets can be read using [`dask`](https://dask.org/) and return as a [`xarray.Dataset`](http://xarray.pydata.org/en/stable/) Other types of binary data, like `dtype` is `station` or`grib`, may be supported in the future.

Expand All @@ -13,7 +13,7 @@ This python package [`xgrads`](https://github.com/miniufo/xgrads) is designed fo
### 2.1 Parse a `.ctl` file
Parsing a `.ctl` file is pretty simple using the following code:
```python
from xgrads.core import CtlDescriptor
from xgrads import CtlDescriptor

ctl = CtlDescriptor(file='test.ctl')

Expand Down Expand Up @@ -46,7 +46,7 @@ print(ctl)
### 2.2 Read binary data into a `xarray.Dataset`
Reading a `.ctl` related binary data file is also pretty simple using the following code:
```python
from xgrads.core import open_CtlDataset
from xgrads import open_CtlDataset

dset = open_CtlDataset('test.ctl')

Expand All @@ -61,7 +61,7 @@ Then you have the `dset` as a `xarray.Dataset`. This is similar to [`xarray.ope
### 2.3 Convert a GrADS dataset to a NetCDF dataset
With the above functionality, it is easy to convert a `.ctl` ([GrADS](http://cola.gmu.edu/grads/)) dataset to a `.nc` ([NetCDF](https://www.unidata.ucar.edu/software/netcdf/docs/file_structure_and_performance.html)) dataset:
```python
from xgrads.core import open_CtlDataset
from xgrads import open_CtlDataset

open_CtlDataset('input.ctl').to_netcdf('output.nc')
```
373 changes: 373 additions & 0 deletions notebooks/Plot preprojected data defined in PDEF.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/test_CtlDescriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
for i in range(10):
print(CtlDescriptor(file='./xgrads/ctls/test'+str(i+1)+'.ctl'))
print('\n')

2 changes: 2 additions & 0 deletions tests/test_openDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# dset = open_CtlDataset('D:/Data/MITgcm/flt/float/Stat.ctl')
# dset = open_CtlDataset('../ctls/test8.ctl')


dset = open_CtlDataset('./xgrads/ctls/test9.ctl')

dset2 = xr.tutorial.open_dataset('air_temperature')

for l in range(len(dset.time)):
xr.testing.assert_equal(dset.air[l], dset2.air[l])

3 changes: 2 additions & 1 deletion xgrads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from .core import CtlDescriptor, open_CtlDataset
from .core import CtlDescriptor
from .io import open_CtlDataset
__version__ = "0.1.0"
Loading