<jupyter_start><jupyter_text>1. Creating LocalAttributes netCDF<jupyter_code>from netCDF4 import Dataset
# Create a netCDF file
LocalAttributes = Dataset("LocalAttri.nc", "w", format="NETCDF3_CLASSIC")
# Create attributes in a netCDF file
LocalAttributes.datasource = "*zLocalAttributes*"
LocalAttributes.history = "Tue Sep 27 21:51:50 2016: ncrename -d nhru,hru -d ngru,gru ./wrrPaperTestCases/figure07/LocalAttri.nc"
LocalAttributes.NCO = "4.6.0"
# Create Dimension in a netCDF file
hru = LocalAttributes.createDimension("hru", 1)
gru = LocalAttributes.createDimension("gru", 1)<jupyter_output><empty_output><jupyter_text>Create variables in a netCDF file for figure07 in wrrPaperTestCases (Clark et al., 2015b)<jupyter_code>hru2gruId = LocalAttributes.createVariable("hru2gruId", "i4", ("hru",))
hru2gruId.long_name = 'Index of GRU to which the HRU belongs'
hru2gruId.units = '-'
hru2gruId[:] = '1001'
downHRUindex = LocalAttributes.createVariable("downHRUindex", "i4", ("hru",))
downHRUindex.long_name = 'Index of downslope HRU (0 = basin outlet)'
downHRUindex.units = '-'
downHRUindex[:] = '0'
slopeTypeIndex = LocalAttributes.createVariable("slopeTypeIndex", "i4", ("hru",))
slopeTypeIndex.long_name = 'Index defining slope'
slopeTypeIndex.units = '-'
slopeTypeIndex[:] = '1'
soilTypeIndex = LocalAttributes.createVariable("soilTypeIndex", "i4", ("hru",))
soilTypeIndex.long_name = 'Index defining soil type'
soilTypeIndex.units = '-'
soilTypeIndex[:] = '8'
vegTypeIndex = LocalAttributes.createVariable("vegTypeIndex", "i4", ("hru",))
vegTypeIndex.long_name = 'Index defining vegetation type'
vegTypeIndex.units = '-'
vegTypeIndex[:] = '11'
mHeight = LocalAttributes.createVariable("mHeight", "f8", ("hru",))
mHeight.long_name = 'Measurement height above bare ground'
mHeight.units = 'm'
mHeight[:] = '19.25'
contourLength = LocalAttributes.createVariable("contourLength", "f8", ("hru",))
contourLength.long_name = 'ContourLength of HRU'
contourLength.units = 'm'
contourLength[:] = '180.83141'
tan_slope = LocalAttributes.createVariable("tan_slope", "f8", ("hru",))
tan_slope.long_name = 'Average tangent slope of HRU'
tan_slope.units = 'm m-1'
tan_slope[:] = '0.20826'
elevation = LocalAttributes.createVariable("elevation", "f8", ("hru",))
elevation.long_name = "Elevation of HRU's centriod point"
elevation.units = 'm'
elevation[:] = '2097.0'
longitude = LocalAttributes.createVariable("longitude", "f8", ("hru",))
longitude.long_name = "Longitude of HRU's centriod point"
longitude.units = 'decimal degree east'
longitude[:] = '243.2'
latitude = LocalAttributes.createVariable("latitude", "f8", ("hru",))
latitude.long_name = "Latitude of HRU's centriod point"
latitude.units = 'decimal degree north'
latitude[:] = '43.2'
HRUarea = LocalAttributes.createVariable("HRUarea", "f8", ("hru",))
HRUarea.long_name = "Area of each HRU"
HRUarea.units = 'm^2'
HRUarea[:] = '32700.0'
hruId = LocalAttributes.createVariable("hruId", "i4", ("hru",))
hruId.long_name = "Ids for hydrological response units"
hruId.units = '-'
hruId.v_type = 'scalarv'
hruId[:] = '1001'
gruId = LocalAttributes.createVariable("gruId", "i4", ("gru",))
gruId.long_name = "Index of group of response unit (GRU)"
gruId.units = '-'
gruId.v_type = 'scalarv'
gruId[:] = '1001'
# Check variables in a netCDF file
LocalAttributes.variables
# Check Dimension in a netCDF file
LocalAttributes.dimensions
# Check a netCDF file
LocalAttributes
# close a netCDF file
LocalAttributes.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1514629948364888, 'fraction_numerical': 0.029546758462421115, 'mean_word_length': 6.90702947845805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '219766', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1248, 'n_words': 283, 'path': 'notebooks/1_Creating_Input_of_SUMMA_Local_Attributes.ipynb', 'repo_name': 'samarthsing/pysumma', 'size': '3486'}