Skip to content

Commit

Permalink
Merge pull request #35 from ldeo-glaciology/change-initialization
Browse files Browse the repository at this point in the history
Change initialization of package and some renaming of key fns/methods and change the name of everything to xapres
  • Loading branch information
jkingslake authored Nov 11, 2023
2 parents b7571fd + 1e67720 commit 23a40ef
Show file tree
Hide file tree
Showing 49 changed files with 6,047 additions and 568 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# channel-priority: true
environment-file: ci/environment-py${{ matrix.python-version }}.yml

activate-environment: test_env_xapres_package
activate-environment: test_env_xapres
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Set up conda environment
shell: bash -l {0}
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# xapres_package
# xapres

A package for processing data from the Autonomous phase-sensitive Radio-Echo Sounder (ApRES) using xarray. The core ApRES processing code is adapted from code written by Keith Nicholls, British Antarctic Survey, UK. This package uses Keith's code to process the raw ApRES data from autonomous ApRES surveys. It then restructures the data into a convenient format using xarray. This simplifies the challenge of dealing with multiple attenuator and gain settings, makes stacking a straight-forward xarray operation, and allows us to store the large datasets in efficient zarr format in cloud storage.
A package for processing data from the Autonomous phase-sensitive Radio-Echo Sounder (ApRES) using xarray. The core ApRES processing code is adapted from code written by Keith Nicholls, British Antarctic Survey, UK. This package uses Keith's code to process the raw ApRES data from ApRES surveys. It then restructures the data into a convenient format using xarray. This simplifies the challenge of dealing with multiple attenuator and gain settings, makes stacking a straight-forward xarray operation, and allows us to store the large datasets in efficient zarr format in cloud storage.

The structure of the resulting xarray depends on if the ApRES data were collected in attended or unattended mode.

## Installation

Expand All @@ -16,29 +18,30 @@ The package includes the capability to write data to zarr stores, which can be a
For example, to lazily access (meaning that no data is downloaded immediately) some recent ApRES data from Greenland, use:

```
import xarray as xr
def reload(site):
filename = f'gs://ldeo-glaciology/apres/greenland/2022/single_zarrs_noencode/{site}'
ds = xr.open_dataset(filename,
engine='zarr',
chunks={})
return ds
A101 = reload("A101')
A103 = reload("A103')
A104 = reload("A104')
A101 = reload("A101")
A103 = reload("A103")
A104 = reload("A104")
```

Alternatively, you can use a function built-in to the package which loads these data, and also adds some functionality to the xarray it returns:

```
import ApRESDefs as xa
import xapres as xa
ds = xa.load_zarr("A101")
ds
```

Now you can compute decibels from a complex profile simply using

```
ds.profile.isel(time=300, chirp_num=0, attenuator_setting_pair=0).db()
ds.profile.isel(time=300, chirp_num=0, attenuator_setting_pair=0).dB()
```

You can also sonify the chirp. Because the frequencies contained in the chirps largely in the audible range, you can play them through the computer's speakers and hear what the ApRES data sound like:
Expand Down
3 changes: 2 additions & 1 deletion ci/environment-py3.10.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_env_xapres_package
name: test_env_xapres
channels:
- conda-forge
dependencies:
Expand All @@ -16,6 +16,7 @@ dependencies:
- gcsfs
- tqdm
- pip
- zarr


##############
Expand Down
3 changes: 2 additions & 1 deletion ci/environment-py3.11.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_env_xapres_package
name: test_env_xapres
channels:
- conda-forge
dependencies:
Expand All @@ -16,6 +16,7 @@ dependencies:
- gcsfs
- tqdm
- pip
- zarr


##############
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py3.8.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_env_xapres_package
name: test_env_xapres
channels:
- conda-forge
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py3.9.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_env_xapres_package
name: test_env_xapres
channels:
- conda-forge
dependencies:
Expand Down
6 changes: 6 additions & 0 deletions data/sample/single_dat_file/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
134 changes: 134 additions & 0 deletions docs/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "6426f368-9d91-498e-8af3-38d98ee6308c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/Users/jkingslake/Documents/science/ApRES/xapres/docs'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pwd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f0a0b6ff-3bbf-4164-aaa7-2714c1259047",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"python exec: /Users/jkingslake/mambaforge/envs/xapres_package/bin/python\n",
"sys.path: ['/Users/jkingslake/Documents/science/ApRES/xapres_package/docs', '/Users/jkingslake/mambaforge/envs/xapres_package/lib/python311.zip', '/Users/jkingslake/mambaforge/envs/xapres_package/lib/python3.11', '/Users/jkingslake/mambaforge/envs/xapres_package/lib/python3.11/lib-dynload', '', '/Users/jkingslake/mambaforge/envs/xapres_package/lib/python3.11/site-packages']\n"
]
},
{
"ename": "NameError",
"evalue": "name '__file__' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 8\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpython exec:\u001b[39m\u001b[38;5;124m\"\u001b[39m, sys\u001b[38;5;241m.\u001b[39mexecutable)\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msys.path:\u001b[39m\u001b[38;5;124m\"\u001b[39m, sys\u001b[38;5;241m.\u001b[39mpath)\n\u001b[0;32m----> 8\u001b[0m root \u001b[38;5;241m=\u001b[39m pathlib\u001b[38;5;241m.\u001b[39mPath(\u001b[38;5;18;43m__file__\u001b[39;49m)\u001b[38;5;241m.\u001b[39mparent\u001b[38;5;241m.\u001b[39mparent\u001b[38;5;241m.\u001b[39mabsolute()\n\u001b[1;32m 9\u001b[0m os\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPYTHONPATH\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(root)\n\u001b[1;32m 10\u001b[0m sys\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39minsert(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mstr\u001b[39m(root))\n",
"\u001b[0;31mNameError\u001b[0m: name '__file__' is not defined"
]
}
],
"source": [
"import os\n",
"import pathlib\n",
"import sys\n",
"\n",
"\n",
"print(\"python exec:\", sys.executable)\n",
"print(\"sys.path:\", sys.path)\n",
"root = pathlib.Path(__file__).parent.parent.absolute()\n",
"os.environ[\"PYTHONPATH\"] = str(root)\n",
"sys.path.insert(0, str(root))\n",
"\n",
"import xapres\n",
"\n",
"\n",
"import xapres # isort:skip\n",
"\n",
"# -- Project information -----------------------------------------------------\n",
"\n",
"project = \"xapres\"\n",
"copyright = \"2021, ldeo_glaciology\"\n",
"author = \"ldeo_glaciology\"\n",
"\n",
"# The version info for the project you're documenting, acts as replacement for\n",
"# |version| and |release|, also used in various other places throughout the\n",
"# built documents.\n",
"# see https://pypi.org/project/setuptools-scm/ for details\n",
"from pkg_resources import get_distribution\n",
"release = get_distribution('xapres').version\n",
"# for example take major/minor\n",
"version = '.'.join(release.split('.')[:2])\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6f6a8539-0354-4917-828e-07dde1995bcb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PosixPath('.')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pathlib.Path()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "615c0f3a-7484-4c47-bade-518e9db08746",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Example For Autogenerated API Documentation
===========================================

.. automodule:: xapres_package.dummy
.. automodule:: xapres.dummy
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
os.environ["PYTHONPATH"] = str(root)
sys.path.insert(0, str(root))

import xapres_package # isort:skip
import xapres # isort:skip

# -- Project information -----------------------------------------------------

project = "xapres_package"
project = "xapres"
copyright = "2021, ldeo_glaciology"
author = "ldeo_glaciology"

Expand All @@ -34,7 +34,7 @@
# built documents.
# see https://pypi.org/project/setuptools-scm/ for details
from pkg_resources import get_distribution
release = get_distribution('xapres_package').version
release = get_distribution('xapres').version
# for example take major/minor
version = '.'.join(release.split('.')[:2])

Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to xapres_package's documentation!
Welcome to xapres's documentation!
=======================================

This is an awesome description of xapres_package, written in `reStructuredText`_.
This is an awesome description of xapres, written in `reStructuredText`_.

You can contribute new sections by either adding a new file (see ``new_section.rst``) or just putting a jupyter notebook
in the ``docs`` folder (see ``new_section_notebook.ipynb``).
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: xapres_package
name: xapres
channels:
- conda-forge
dependencies:
Expand All @@ -20,3 +20,4 @@ dependencies:
- gcsfs
- tqdm
- pip
- zarr
2 changes: 1 addition & 1 deletion notebooks/guides/sonify.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"/Users/jkingslake/Documents/science/ApRES/xapres_package/xapres_package/\")\n",
"sys.path.append(\"/Users/jkingslake/Documents/science/ApRES/xapres/xapres/\")\n",
"import ApRESDefs\n"
]
},
Expand Down
Loading

0 comments on commit 23a40ef

Please sign in to comment.