A toolkit for processing CWA long-term observation station data from https://asrad.pccu.edu.tw.
Project description
About This Repository
asrad-reader is a small Python package for reading CWA long-term observational data from ASRAD and turning it into a pandas-friendly dataset.
This project is built around two ideas:
- quick loading of many observation files with multi-threading
- convenient time-series processing through a pandas
DataFrameextension
The main public entry points are:
asrad-reader.load_fileasrad-reader.load_folderasrad-reader.NanMode- the
obsDataFrame accessor on returned datasets
Current Structure
asrad-reader/
__init__.py
loader.py
nan_mode.py
obs_data_frame.py
special_value.py
main.py
readme.md
read_me.html
setup.py
test_read/
_run_notebook_check.py
read_folder_test.ipynb
Development Environment
- Python 3.11.7 or higher
- NumPy 1.26.2 or higher
- pandas 2.1.4 or higher
Installation
For published releases, users should install the package from PyPI:
pip install asrad-reader
For local development in this repository, install in editable mode from the repository root:
pip install -e .
Getting Started
Import the package and the NaN mode enum:
from pathlib import Path
from asrad-reader import NanMode, load_file, load_folder
Read a File
file_path = Path("datas/20029999_cwb_hr/20021099.cwb_hr.txt")
df = load_file(file_path)
load_file supports these parameters:
mode: controls which special values are treated as NaN. Default isNanMode.AllEmpty.drop_nan: removes rows whose data columns are all missing. Default isFalse.is_utf8:Truefor UTF-8,Falsefor Big5. Default isTrue.
Available NanMode values:
| Mode | Description |
|---|---|
ObsEmpty |
Missing because of observation-related reasons |
AllEmpty |
All special values |
NotInObs |
Missing because the station was not observed |
Read a Folder
folder_path = Path("datas")
df = load_folder(folder_path)
load_folder reads all .txt files under the folder with multi-threading.
Supported parameters:
mode: defaultNanMode.AllEmptymax_threads: default4drop_nan: defaultFalseselected_cols: columns to keep, defaultNonemeans keep the default observation columnsstation_number: filter a specific station, defaultNone
DataFrame Accessor
The returned object is an ObsDataFrame, so you can also use the registered accessor:
df.obs.station("467490")
df.obs.get_item_with_time(["TX01", "PP01", "RH01"])
df.obs.find_observe_patterns()
df.obs.find_nan_periods()
The accessor expects a # stno column and either a datetime column or a DatetimeIndex.
Notes
ASRAD_reader.__init__exportsNanMode,ObsDataFrame,ObservePattern,NanPeriod,load_file, andload_folder.ASRAD_readeris intended to be used as a library, not as a standalone script.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asrad_reader-0.4.5.tar.gz.
File metadata
- Download URL: asrad_reader-0.4.5.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
696a5ea22f6eac1e7409c2b9f4f780806a79e473b9f834c03a578ca7068631c8
|
|
| MD5 |
c4c3e11c77ce662a2046f0ac36d912aa
|
|
| BLAKE2b-256 |
11c06454aab16157d1bc3df9bf677418cfd76a3bd28fa2fef19a3ab0ac29d2e4
|
File details
Details for the file asrad_reader-0.4.5-py3-none-any.whl.
File metadata
- Download URL: asrad_reader-0.4.5-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3e4949afb512848b8ef8bb1795106b36cefa6761bd629180c8dde44d95514e8
|
|
| MD5 |
abac66c8d489a26d8c4d77d6ed0d5401
|
|
| BLAKE2b-256 |
f5ad5d992a430711af2fa30ab00a4291f31af3c91152b15b193567b55c06819f
|