Skip to main content

Code to process ion spectrometer data files

Project description

NAIS processor

Use this code package to process NAIS (Neutral cluster and Air Ion Spectrometer, Airel Ltd.) data files.

The code corrects for diffusion losses in the inlet line (Gromley and Kennedy, 1948) and applies an ion mode calibration (Wagner et al. 2016). Optionally the data can be corrected to standard conditions (273.15 K, 101325 Pa), which can be useful when comparing aerosol particle and ion data from various locations at different altitudes.

Installation

pip install nais-processor

Documentation

Example usage

Open the python prompt and load methods from the nais_processor module. Then use the make_config() method to create a configuration file that is used at processing the data files.

$ python
>>> from nais_processor import *
>>> make_config()

Enter name of configuration file.
E.g. ./configs/campaign.yml
> ./nais-5-33.yml  

Give path(s) to raw data. If multiple paths give them as comma separated list.
E.g. /data/nais/2021,/data/nais/2022
> ./nais-5-33

Path to where processed data is saved.
E.g. ./data/campaign/processed
> ./nais-5-33

Path to where figures are saved. Leave empty if no figures.
E.g. ./data/campaign/figures
> ./nais-5-33   

Start of measurement (YYYY-MM-DD)
> 2022-09-28

End of measurement (YYYY-MM-DD)
If empty processor assumes current day, use for continuous measurements.
> 2022-09-30

Enter name of database file
E.g. ./logs/campaign.json
> ./nais-5-33.json  

Allow reprocessing (True/False)
Overwrites already processed datafiles in the database when running the processor again.
> True

Measurement location
E.g. Helsinki, Kumpula
> Helsinki, Lab 

Apply corrections to data? (True/False)
Requires a NAIS with temperature and pressure sensors.
> True 

Length of the inlet in meters
> 0.0 

Correct concentrations to sealevel conditions? (True/False)
> False

Configuration saved to: ./nais-5-33.yml

The resulting configuration file nais-5-33.yml looks like this:

allow_reprocess: true
apply_corrections: true
data_folder:
- ./nais-5-33
database_file: ./nais-5-33.json
end_date: '2022-09-30'
figure_folder: ./nais-5-33
inlet_length: 0.0
location: Helsinki, Lab
processed_folder: ./nais-5-33
sealevel_correction: false
start_date: '2022-09-28'

Then process the data files by running nais_processor() method with the config file as the input argument.

>>> nais_processor("./nais-5-33.yml")
Configuration file: ./nais-5-33.yml
processing 20220928
processing 20220929
processing 20220930
Done!

Run do_daily_figs() with the config file in order to create plots of the processed data if needed.

>>> do_daily_figs("./nais-5-33.yml")
plotting 20220928
plotting 20220929
plotting 20220930
Done!

The code produces daily processed data files and optionally figures for ion and particle data. These files are saved in the destinations given in the configuration file.

The data files are named

NAIS[n|p][yyyymmdd][np|nds].sum

where n and p refer to negative and positive polarity respectively. yyyymmdd tells the date in the year-month-day format. np and nds refer to particle and ion data respectively.

The data files have the following structure:

[0,0]  = UTC offset in hours
[1:,0] = Time (MATLAB datenum) 
[0,2:] = Geometric mean diameter of size-channel (m)
[1:,1] = Integrated total number concentration (cm-3)
[1:,2:] = Normalized number concentrations, dN/dlogDp (cm-3)

The locations of raw files, processed files and possible figures are written in the database_file, which is in JSON format.

Combining sumfiles

Once you have processed your NAIS data you can combine multiple daily sumfiles into a single multi-day sumfile using the combine_spectra() function. You can also extract data from within one day like this.

Example:

import nais_processor as nais

start_time="2020-07-04 20:00:00"
end_time="2020-07-08 12:00:00"

combined_data = nais.combine_spectra(
    config_file,start_time,end_time,spectra_type="negion")

The spectra types are: negion (default), posion, negpar and pospar.

You can also plot data using plot_sumfile().

License

This project is licensed under the terms of the GNU GPLv3.

References

Gormley P. G. and Kennedy M., Diffusion from a Stream Flowing through a Cylindrical Tube, Proceedings of the Royal Irish Academy. Section A: Mathematical and Physical Sciences, 52, (1948-1950), pp. 163-169.

Wagner R., Manninen H.E., Franchin A., Lehtipalo K., Mirme S., Steiner G., Petäjä T. and Kulmala M., On the accuracy of ion measurements using a Neutral cluster and Air Ion Spectrometer, Boreal Environment Research, 21, (2016), pp. 230–241.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nais-processor-0.0.3.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

nais_processor-0.0.3-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file nais-processor-0.0.3.tar.gz.

File metadata

  • Download URL: nais-processor-0.0.3.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for nais-processor-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7cd3d0be952ed9238476aa4cc7a6c44718a4276142c49cdf554bbcb780ad7dc1
MD5 4b3430b7c01c40e57eed1964e44f6578
BLAKE2b-256 92a3e22b7331a6c876adcdf5619067681261dd2bacd590ef8b6eacbc7feb5185

See more details on using hashes here.

File details

Details for the file nais_processor-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nais_processor-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45d0e91a135c321eefe504cbc0a9f5d3e6f9c0e1aaf0042c41b9c15b3188ea37
MD5 d981107f63e6af190afc9e0fe904973a
BLAKE2b-256 7b3f31c72b69e5142c3417a1b497d44bceda070b2fa1d63871b9c3d51657894f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page