ncBuilder
Project description
ncBuilder
netCDF4 tool to help creating new files from scratch, and loading variables from existing ones.
example
from ncBuilder import (
ncBuilder,
ncHelper,
)
import datetime as dt
import numpy as np
import pandas as pd
dtNow = dt.datetime.now()
times = pd.date_range('2021-01-01', periods=10).to_pydatetime()
lat = np.arange(-30., 10. + 0.05, 0.05)
lon = np.arange(-60., -30 + 0.05, 0.05)
temp = np.random.rand(times.size, lat.size, lon.size)
nc_file = ncBuilder.initialize_nc(dtNow, '/path/to/file', '_suffix.nc')
# or
nc_file = nc.Dataset('your_nc_file.nc', 'w')
# nc_file = ncBuilder.initialize_nc('file_name_here', '/path/to/file', '_suffix.nc')
# creating dimensions
ncBuilder.create_nc(nc_file,
lat,
lon,
time=times)
# or create variables while creating dimensions
ncBuilder.create_nc(nc_file,
lat,
lon,
time=times,
vars={'temp': {'dims': ('time', 'latitude', 'longitude'),
'units': 'ºC',
'standard_name': 'temperature in ºC',
},
})
# creating a single variable
ncBuilder.create_nc_variable(nc_file,
'temp',
comp_lvl=6,
dims=('time',
'latitude',
'longitude'),
dtype=np.float64,
units='°C',
standard_name='temperature in °C')
# updating a variable
ncBuilder.update_nc(nc_file, 'temp', temp)
# updating partially a variable
ncBuilder.update_nc(nc_file, 'temp', temp[:, 5:, :-5], dims=(slice(None),
slice(5, None),
slice(None, -5)))
# loading time
times = ncHelper.load_time(nc_file.variables['time'])
# getting lats and lons
lats, lons = ncHelper.get_lats_lons(nc_file)
# getting nearest point
idx, jdx = ncHelper.get_idx_pos(lat0, lon0, lats, lons)
# closing the nc_file
nc_file.close()
version 0.0.7a
- Packages are now installed with the lib, they were not configured properly.
version 0.0.7
- Added create_nc_dimension, so new custom dimensions can be easily added.
- Minor modifications to the inner creation of dimensions to accomodate the new function.
version 0.0.6
- Added zlib, fill_value and variable_kw when creating a new variable, so it's more customizable
- Changed the way dimension variables are created for more consistency of the process
version 0.0.5
- Added ncHelper, which contains load_time, get_lats_lons and get_idx_pos
version 0.0.3
- Modified function names to use snake_style pattern
- Comments added to the main functions
- Example updated to follow the new patterns
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
ncBuilder-0.0.7a0.tar.gz
(7.1 kB
view details)
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 ncBuilder-0.0.7a0.tar.gz.
File metadata
- Download URL: ncBuilder-0.0.7a0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e998a12e34bbdf27790f5f763515582b070fd00e17ba9a2462ca60d878220e
|
|
| MD5 |
893a8afc86279cd231dbb5b3be7122f3
|
|
| BLAKE2b-256 |
df8923efd1e453d828fb9a33c7d434c29ad87adba4390ae4912a7f1e833e23c1
|
File details
Details for the file ncBuilder-0.0.7a0-py3-none-any.whl.
File metadata
- Download URL: ncBuilder-0.0.7a0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd1d6e003f976325180657a056befea40a91867652ccd2cea630874778d7d012
|
|
| MD5 |
b8129e9558e36e67f9d5f01b8481fbbf
|
|
| BLAKE2b-256 |
01490d3dae5a69e56565405dbf9b802c2d00c77cf102c9d1c21c4b479b5cc188
|