|
| 1 | +import numpy as np |
| 2 | +import netCDF4 |
| 3 | +import sys |
| 4 | + |
| 5 | +# This program splits the large phytoplankton into large and medium. |
| 6 | +# True for nitrogen, iron, and silicon. |
| 7 | +# Copy the original file before running this, then operate on the copy. |
| 8 | +# Could probably do this with ncap2 instead. |
| 9 | +# |
| 10 | +ncfile = sys.argv[1] |
| 11 | +nc = netCDF4.Dataset(ncfile, 'a', format='NETCDF3_CLASSIC') |
| 12 | +spval = -10000000000. |
| 13 | + |
| 14 | +nlg = nc.variables['nlg_north'][:] |
| 15 | +nlg *= 0.5 |
| 16 | +nc.variables['nlg_north'][:] = nlg |
| 17 | + |
| 18 | +nc.createVariable('nmd_north', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 19 | +nc.variables['nmd_north'].long_name = 'Medium Phytoplankton Nitrogen north boundary condition' |
| 20 | +nc.variables['nmd_north'].units = 'mol/kg' |
| 21 | +nc.variables['nmd_north'].time = 'ocean_time' |
| 22 | +nc.variables['nmd_north'].field = 'nmd_north, scalar, series' |
| 23 | +nc.variables['nmd_north'][:] = nlg |
| 24 | + |
| 25 | +felg = nc.variables['felg_north'][:] |
| 26 | +felg *= 0.5 |
| 27 | +nc.variables['felg_north'][:] = felg |
| 28 | + |
| 29 | +nc.createVariable('femd_north', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 30 | +nc.variables['femd_north'].long_name = 'Medium Phytoplankton Iron north boundary condition' |
| 31 | +nc.variables['femd_north'].units = 'mol/kg' |
| 32 | +nc.variables['femd_north'].time = 'ocean_time' |
| 33 | +nc.variables['femd_north'].field = 'femd_north, scalar, series' |
| 34 | +nc.variables['femd_north'][:] = felg |
| 35 | + |
| 36 | +silg = nc.variables['silg_north'][:] |
| 37 | +silg *= 0.5 |
| 38 | +nc.variables['silg_north'][:] = silg |
| 39 | + |
| 40 | +nc.createVariable('simd_north', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 41 | +nc.variables['simd_north'].long_name = 'Medium Phytoplankton Silicon north boundary condition' |
| 42 | +nc.variables['simd_north'].units = 'mol/kg' |
| 43 | +nc.variables['simd_north'].time = 'ocean_time' |
| 44 | +nc.variables['simd_north'].field = 'simd_north, scalar, series' |
| 45 | +nc.variables['simd_north'][:] = silg |
| 46 | + |
| 47 | + |
| 48 | +nlg = nc.variables['nlg_south'][:] |
| 49 | +nlg *= 0.5 |
| 50 | +nc.variables['nlg_south'][:] = nlg |
| 51 | + |
| 52 | +nc.createVariable('nmd_south', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 53 | +nc.variables['nmd_south'].long_name = 'Medium Phytoplankton Nitrogen south boundary condition' |
| 54 | +nc.variables['nmd_south'].units = 'mol/kg' |
| 55 | +nc.variables['nmd_south'].time = 'ocean_time' |
| 56 | +nc.variables['nmd_south'].field = 'nmd_south, scalar, series' |
| 57 | +nc.variables['nmd_south'][:] = nlg |
| 58 | + |
| 59 | +felg = nc.variables['felg_south'][:] |
| 60 | +felg *= 0.5 |
| 61 | +nc.variables['felg_south'][:] = felg |
| 62 | + |
| 63 | +nc.createVariable('femd_south', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 64 | +nc.variables['femd_south'].long_name = 'Medium Phytoplankton Iron south boundary condition' |
| 65 | +nc.variables['femd_south'].units = 'mol/kg' |
| 66 | +nc.variables['femd_south'].time = 'ocean_time' |
| 67 | +nc.variables['femd_south'].field = 'femd_south, scalar, series' |
| 68 | +nc.variables['femd_south'][:] = felg |
| 69 | + |
| 70 | +silg = nc.variables['silg_south'][:] |
| 71 | +silg *= 0.5 |
| 72 | +nc.variables['silg_south'][:] = silg |
| 73 | + |
| 74 | +nc.createVariable('simd_south', 'f8', ('ocean_time', 's_rho', 'xi_rho'), fill_value=spval) |
| 75 | +nc.variables['simd_south'].long_name = 'Medium Phytoplankton Silicon south boundary condition' |
| 76 | +nc.variables['simd_south'].units = 'mol/kg' |
| 77 | +nc.variables['simd_south'].time = 'ocean_time' |
| 78 | +nc.variables['simd_south'].field = 'simd_south, scalar, series' |
| 79 | +nc.variables['simd_south'][:] = silg |
| 80 | + |
| 81 | +nlg = nc.variables['nlg_west'][:] |
| 82 | +nlg *= 0.5 |
| 83 | +nc.variables['nlg_west'][:] = nlg |
| 84 | + |
| 85 | +nc.createVariable('nmd_west', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 86 | +nc.variables['nmd_west'].long_name = 'Medium Phytoplankton Nitrogen west boundary condition' |
| 87 | +nc.variables['nmd_west'].units = 'mol/kg' |
| 88 | +nc.variables['nmd_west'].time = 'ocean_time' |
| 89 | +nc.variables['nmd_west'].field = 'nmd_west, scalar, series' |
| 90 | +nc.variables['nmd_west'][:] = nlg |
| 91 | + |
| 92 | +felg = nc.variables['felg_west'][:] |
| 93 | +felg *= 0.5 |
| 94 | +nc.variables['felg_west'][:] = felg |
| 95 | + |
| 96 | +nc.createVariable('femd_west', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 97 | +nc.variables['femd_west'].long_name = 'Medium Phytoplankton Iron west boundary condition' |
| 98 | +nc.variables['femd_west'].units = 'mol/kg' |
| 99 | +nc.variables['femd_west'].time = 'ocean_time' |
| 100 | +nc.variables['femd_west'].field = 'femd_west, scalar, series' |
| 101 | +nc.variables['femd_west'][:] = felg |
| 102 | + |
| 103 | +silg = nc.variables['silg_west'][:] |
| 104 | +silg *= 0.5 |
| 105 | +nc.variables['silg_west'][:] = silg |
| 106 | + |
| 107 | +nc.createVariable('simd_west', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 108 | +nc.variables['simd_west'].long_name = 'Medium Phytoplankton Silicon west boundary condition' |
| 109 | +nc.variables['simd_west'].units = 'mol/kg' |
| 110 | +nc.variables['simd_west'].time = 'ocean_time' |
| 111 | +nc.variables['simd_west'].field = 'simd_west, scalar, series' |
| 112 | +nc.variables['simd_west'][:] = silg |
| 113 | + |
| 114 | +nlg = nc.variables['nlg_east'][:] |
| 115 | +nlg *= 0.5 |
| 116 | +nc.variables['nlg_east'][:] = nlg |
| 117 | + |
| 118 | +nc.createVariable('nmd_east', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 119 | +nc.variables['nmd_east'].long_name = 'Medium Phytoplankton Nitrogen east boundary condition' |
| 120 | +nc.variables['nmd_east'].units = 'mol/kg' |
| 121 | +nc.variables['nmd_east'].time = 'ocean_time' |
| 122 | +nc.variables['nmd_east'].field = 'nmd_east, scalar, series' |
| 123 | +nc.variables['nmd_east'][:] = nlg |
| 124 | + |
| 125 | +felg = nc.variables['felg_east'][:] |
| 126 | +felg *= 0.5 |
| 127 | +nc.variables['felg_east'][:] = felg |
| 128 | + |
| 129 | +nc.createVariable('femd_east', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 130 | +nc.variables['femd_east'].long_name = 'Medium Phytoplankton Iron east boundary condition' |
| 131 | +nc.variables['femd_east'].units = 'mol/kg' |
| 132 | +nc.variables['femd_east'].time = 'ocean_time' |
| 133 | +nc.variables['femd_east'].field = 'femd_east, scalar, series' |
| 134 | +nc.variables['femd_east'][:] = felg |
| 135 | + |
| 136 | +silg = nc.variables['silg_east'][:] |
| 137 | +silg *= 0.5 |
| 138 | +nc.variables['silg_east'][:] = silg |
| 139 | + |
| 140 | +nc.createVariable('simd_east', 'f8', ('ocean_time', 's_rho', 'eta_rho'), fill_value=spval) |
| 141 | +nc.variables['simd_east'].long_name = 'Medium Phytoplankton Silicon east boundary condition' |
| 142 | +nc.variables['simd_east'].units = 'mol/kg' |
| 143 | +nc.variables['simd_east'].time = 'ocean_time' |
| 144 | +nc.variables['simd_east'].field = 'simd_east, scalar, series' |
| 145 | +nc.variables['simd_east'][:] = silg |
| 146 | + |
| 147 | +nc.close() |
0 commit comments