Example #1
0
 def compute(self, inputs):
     self.make_storage_data_input_vars(inputs)
     inputs["jm"] = 1
     for name, value in tuple(inputs.items()):
         if hasattr(
                 value,
                 "shape") and len(value.shape) > 1 and value.shape[1] == 1:
             inputs[name] = self.make_storage_data(
                 pad_field_in_j(value, self.grid.njd))
     for name, value in tuple(inputs["tracers"].items()):
         if hasattr(
                 value,
                 "shape") and len(value.shape) > 1 and value.shape[1] == 1:
             inputs["tracers"][name] = self.make_storage_data(
                 pad_field_in_j(value, self.grid.njd))
     run_fillz = fillz.FillNegativeTracerValues(
         self.grid.stencil_factory,
         inputs.pop("im"),
         inputs.pop("jm"),
         inputs.pop("km"),
         inputs.pop("nq"),
     )
     run_fillz(**inputs)
     ds = self.grid.default_domain_dict()
     ds.update(self.out_vars["q2tracers"])
     tracers = np.zeros(
         (self.grid.nic, self.grid.npz, len(inputs["tracers"])))
     for varname, data in inputs["tracers"].items():
         index = utils.tracer_variables.index(varname)
         tracers[:, :, index] = np.squeeze(data[self.grid.slice_dict(ds)])
     out = {"q2tracers": tracers}
     return out
Example #2
0
    def compute(self, inputs):
        self.setup(inputs)
        inputs["j_2d"] = self.grid.global_to_local_y(
            inputs["j_2d"] + TranslateGrid.fpy_model_index_offset)
        inputs["i1"] = self.is_
        inputs["i2"] = self.ie
        inputs["j1"] = inputs["j_2d"]
        inputs["j2"] = inputs["j_2d"]
        del inputs["j_2d"]
        inputs["kord"] = abs(spec.namelist.kord_tm)
        inputs["qmin"] = 184.0
        # these are sometimes 3D and sometimes singleton in J
        if inputs["pe1"].shape[1] == 1:
            inputs["pe1"] = self.make_storage_data(
                pad_field_in_j(inputs["pe1"], self.nj))
        if inputs["pe2"].shape[1] == 1:
            inputs["pe2"] = self.make_storage_data(
                pad_field_in_j(inputs["pe2"], self.nj))

        qs_field = utils.make_storage_from_shape(self.maxshape[0:2],
                                                 origin=(0, 0))
        qs_field[:, :] = inputs["qs"][:, :, 0]
        inputs["qs"] = qs_field
        if inputs["qs"].shape[1] == 1:
            inputs["qs"] = utils.tile(inputs["qs"][:, 0],
                                      [self.nj, 1]).transpose(1, 0)
        var_inout = self.compute_func(**inputs)
        return self.slice_output(inputs, {"pt": var_inout})
Example #3
0
 def compute(self, inputs):
     self.setup(inputs)
     inputs["j_2d"] = self.grid.global_to_local_y(
         inputs["j_2d"] + TranslateGrid.fpy_model_index_offset)
     inputs["i1"] = self.is_
     inputs["i2"] = self.ie
     inputs["j1"] = inputs["j_2d"]
     inputs["j2"] = inputs["j_2d"]
     del inputs["j_2d"]
     inputs["pe1"] = self.make_storage_data(
         pad_field_in_j(inputs["pe1"], self.grid.njd))
     inputs["pe2"] = self.make_storage_data(
         pad_field_in_j(inputs["pe2"], self.grid.njd))
     inputs["dp2"] = self.make_storage_data(
         pad_field_in_j(inputs["dp2"], self.grid.njd))
     inputs["kord"] = abs(spec.namelist.kord_tr)
     self.compute_func = MapN_Tracer.MapNTracer(
         self.grid.stencil_factory,
         inputs.pop("kord"),
         inputs.pop("nq"),
         inputs.pop("i1"),
         inputs.pop("i2"),
         inputs.pop("j1"),
         inputs.pop("j2"),
         fill=spec.namelist.fill,
     )
     self.compute_func(**inputs)
     return self.slice_output(inputs)
Example #4
0
 def compute_from_storage(self, inputs):
     for name, value in inputs.items():
         if hasattr(
                 value,
                 "shape") and len(value.shape) > 1 and value.shape[1] == 1:
             inputs[name] = self.make_storage_data(
                 pad_field_in_j(value, self.grid.njd))
     self.compute_func(**inputs)
     return inputs
 def compute(self, inputs):
     self.make_storage_data_input_vars(inputs)
     if "qs" in inputs:
         qs_field = utils.make_storage_from_shape(self.maxshape[0:2], origin=(0, 0))
         qs_field[:, :] = inputs["qs"][:, :, 0]
         inputs["qs"] = qs_field
         if inputs["qs"].shape[1] == 1:
             inputs["qs"] = utils.tile(inputs["qs"][:, 0], [self.nj, 1]).transpose(
                 1, 0
             )
     inputs["i1"] = self.grid.global_to_local_x(
         inputs["i1"] + TranslateGrid.fpy_model_index_offset
     )
     inputs["i2"] = self.grid.global_to_local_x(
         inputs["i2"] + TranslateGrid.fpy_model_index_offset
     )
     inputs["qmin"] = 0.0
     inputs["j_2d"] = self.grid.global_to_local_y(
         inputs["j_2d"] + TranslateGrid.fpy_model_index_offset
     )
     if inputs["q1"].shape[1] == 1:
         # some test cases are on singleton j-slices,
         # so for those calls these are zero and not n_halo
         inputs["j1"] = 0
         inputs["j2"] = 0
     else:
         inputs["j1"] = inputs["j_2d"]
         inputs["j2"] = inputs["j_2d"]
         if inputs["pe1"].shape[1] == 1:
             inputs["pe1"] = self.make_storage_data(
                 pad_field_in_j(inputs["pe1"], self.nj)
             )
         if inputs["pe2"].shape[1] == 1:
             inputs["pe2"] = self.make_storage_data(
                 pad_field_in_j(inputs["pe2"], self.nj)
             )
     del inputs["j_2d"]
     var_inout = self.compute_func(**inputs)
     return self.slice_output(inputs, {"var_inout": var_inout})