Skip to main content

ncBuilder

Project description

ncBuilder

netCDF4 tool to help creating new files from scratch

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

example

from ncBuilder import ncBuilder
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')
# nc_file = ncBuilder.initialize_nc('file_name_here', '/path/to/file', '_suffix.nc')

# creating dimensions
ncBuilder.create_nc(nc_file, lat, lon, time=times)

# 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), ))

# closing the nc_file
nc_file.close()

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

ncBuilder-0.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncBuilder-0.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ncBuilder-0.0.3.tar.gz.

File metadata

  • Download URL: ncBuilder-0.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3

File hashes

Hashes for ncBuilder-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cb158f374d4d8ebc7ad7551c4cbabc82c5c0ce8a301ed36c1396ad31885b22f7
MD5 882cfb81793f12206c5ff104fb874ffb
BLAKE2b-256 798199db6b55d601e68ded6c2ef5c5d177090e0483d2f65a3b5a699aa0eaeb87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncBuilder-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3

File hashes

Hashes for ncBuilder-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae0a3884d5e5bca342950003a93ff1374876193c34049f2ab229b2709db7696d
MD5 6cf5f0c71fde16bc799a436a06a3c87f
BLAKE2b-256 ebee98668defbb00a7718d1f0992ade3b7b8217808ebbb4ef36121c4865478df

See more details on using hashes here.

Supported by

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