(outfile, var, varname)
| 70 | |
| 71 | |
| 72 | def add_to_ncfile(outfile, var, varname): |
| 73 | dim_d = dict(zip(var.dims, var.shape)) |
| 74 | |
| 75 | for dimname, dimsize in dim_d.items(): |
| 76 | if dimname not in outfile.dimensions: |
| 77 | outfile.createDimension(dimname, dimsize) |
| 78 | |
| 79 | fill_value = None |
| 80 | if "_FillValue" in var.attrs: |
| 81 | fill_value = var.attrs["_FillValue"] |
| 82 | |
| 83 | ncvar = outfile.createVariable(varname, var.dtype, var.dims, |
| 84 | zlib=True, fill_value=fill_value) |
| 85 | |
| 86 | var_vals = to_np(var) |
| 87 | ncvar[:] = var_vals[:] |
| 88 | |
| 89 | |
| 90 | def make_result_file(opts): |
no test coverage detected