How to use the yt.funcs.mylog.warning function in yt

To help you get started, we’ve selected a few yt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yt-project / yt / yt / frontends / ramses / fields.py View on Github external
self.add_field(name=name, sampling_type="cell", function=_func,
                           units=unit)

        #Load cooling files
        avals = {}
        tvals = {}
        with FortranFile(filename) as fd:
            n1, n2 = fd.read_vector('i')
            for ax in _cool_axes:
                avals[ax] = fd.read_vector('d')
            for i,(tname, unit) in enumerate(_cool_arrs):
                var = fd.read_vector('d')
                if var.size==n1 and i==0:
                    #If this case occurs, the cooling files were produced pre-2010 in a format
                    #that is no longer supported
                    mylog.warning('This cooling file format is no longer supported. Cooling field loading skipped.')
                    return
                if var.size == n1*n2:
                    tvals[tname] = dict(data=var.reshape((n1, n2), order='F'), unit=unit)
                else:
                    var = var.reshape((n1, n2, var.size // (n1*n2)), order='F')
                    for i in range(var.shape[-1]):
                        tvals[_cool_species[i]] = dict(data=var[:,:,i], unit="1/cm**3")

        #Add the mu field first, as it is needed for the number density
        interp = BilinearFieldInterpolator(tvals['mu']['data'],
                                           (avals["lognH"], avals["logT"]),
                                           ["lognH", "logT"], truncate = True)
        _create_field(("gas", 'mu'), interp, tvals['mu']['unit'])

        #Add the number density field, based on mu
        def _number_density(field,data):
github yt-project / yt / yt / frontends / arepo / data_structures.py View on Github external
def _get_uvals(self):
        handle = h5py.File(self.parameter_filename, mode="r")
        uvals = {}
        missing = False
        for unit in ["UnitLength_in_cm", "UnitMass_in_g", 
                     "UnitVelocity_in_cm_per_s"]:
            if unit in handle["/Header"].attrs:
                uvals[unit] = handle["/Header"].attrs[unit]
            else:
                mylog.warning("Arepo header is missing %s!" % unit)
                missing = True
        handle.close()
        if missing:
            uvals = None
        return uvals
github yt-project / yt / yt / analysis_modules / halo_finding / halo_objects.py View on Github external
def _get_dm_indices(self):
        if ('io','creation_time') in self._data_source.index.field_list:
            mylog.debug("Differentiating based on creation time")
            return (self._data_source["creation_time"] <= 0)
        elif ('io','particle_type') in self._data_source.index.field_list:
            mylog.debug("Differentiating based on particle type")
            return (self._data_source["particle_type"] == 1)
        else:
            mylog.warning("No particle_type, no creation_time, so not distinguishing.")
            return slice(None)
github yt-project / yt / yt / visualization / plot_modifications.py View on Github external
verts = np.array(
                [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),
                 (left_edge_y, right_edge_y, right_edge_y, left_edge_y)])
            verts=verts.transpose()[visible,:,:]
            grid_collection = matplotlib.collections.PolyCollection(
                verts, facecolors="none", edgecolors=edgecolors,
                linewidth=self.linewidth)
            plot._axes.add_collection(grid_collection)

            visible_ids = np.logical_and(
                    np.logical_and(xwidth > self.min_pix_ids,
                                   ywidth > self.min_pix_ids),
                    np.logical_and(levels >= min_level, levels <= max_level))

            if self.id_loc and not self.draw_ids:
                mylog.warning("Supplied id_loc but draw_ids is False. Not drawing grid ids")

            if self.draw_ids:
                id_loc = self.id_loc.lower() # Make case-insensitive
                plot_ids = np.where(visible_ids)[0]
                x = np.empty(plot_ids.size)
                y = np.empty(plot_ids.size)
                for i,n in enumerate(plot_ids):
                    if id_loc == "lower left":
                        x[i] = left_edge_x[n] + (2 * (xx1 - xx0) / xpix)
                        y[i] = left_edge_y[n] + (2 * (yy1 - yy0) / ypix)
                    elif id_loc == "lower right":
                        x[i] = right_edge_x[n] - ((10*len(str(block_ids[i]))-2)\
                                                   * (xx1 - xx0) / xpix)
                        y[i] = left_edge_y[n] + (2 * (yy1 - yy0) / ypix)
                    elif id_loc == "upper left":
                        x[i] = left_edge_x[n] + (2 * (xx1 - xx0) / xpix)
github yt-project / yt / yt / frontends / flash / data_structures.py View on Github external
nxb = self.parameters["nxb"]
            nyb = self.parameters["nyb"]
            nzb = self.parameters["nzb"]
        except KeyError:
            nxb, nyb, nzb = [int(self._handle["/simulation parameters"]['n%sb' % ax])
                             for ax in 'xyz'] # FLASH2 only!
        
        # Determine dimensionality
        try:
            dimensionality = self.parameters["dimensionality"]
        except KeyError:
            dimensionality = 3
            if nzb == 1: dimensionality = 2
            if nyb == 1: dimensionality = 1
            if dimensionality < 3:
                mylog.warning("Guessing dimensionality as %s", dimensionality)
        
        self.dimensionality = dimensionality

        self.geometry = self.parameters["geometry"]
        # Determine base grid parameters
        if 'lrefine_min' in self.parameters.keys(): # PARAMESH
            nblockx = self.parameters["nblockx"]
            nblocky = self.parameters["nblocky"]
            nblockz = self.parameters["nblockz"]
        else: # Uniform Grid
            nblockx = self.parameters["iprocs"]
            nblocky = self.parameters["jprocs"]
            nblockz = self.parameters["kprocs"]

        # In case the user wasn't careful
        if self.dimensionality <= 2: nblockz = 1
github yt-project / yt / yt / frontends / gamer / data_structures.py View on Github external
if self.parameters['Opt__Unit']:
            # GAMER units are always in CGS
            setdefaultattr( self, 'length_unit', self.quan(self.parameters['Unit_L'], 'cm') )
            setdefaultattr( self, 'mass_unit',   self.quan(self.parameters['Unit_M'], 'g' ) )
            setdefaultattr( self, 'time_unit',   self.quan(self.parameters['Unit_T'], 's' ) )

        else:
            if len(self.units_override) == 0:
                mylog.warning("Cannot determine code units ==> " +
                              "Use units_override to specify the units")

            for unit, cgs in [("length", "cm"), ("time", "s"), ("mass", "g")]:
                setdefaultattr(self, "%s_unit"%unit, self.quan(1.0, cgs))

                if len(self.units_override) == 0:
                    mylog.warning("Assuming %s unit = 1.0 %s", unit, cgs)
github yt-project / yt / yt / visualization / plot_window.py View on Github external
elif not np.any(np.isfinite(image)):
                    msg = "Plot image for field %s is filled with NaNs." % (f,)
                elif np.nanmax(image) > 0. and np.nanmin(image) < 0:
                    msg = "Plot image for field %s has both positive "\
                          "and negative values. Min = %f, Max = %f."\
                          % (f, np.nanmin(image), np.nanmax(image))
                    use_symlog = True
                if msg is not None:
                    mylog.warning(msg)
                    if use_symlog:
                        mylog.warning("Switching to symlog colorbar scaling "\
                                      "unless linear scaling is specified later")
                        self._field_transform[f] = symlog_transform
                        self._field_transform[f].func = None
                    else:
                        mylog.warning("Switching to linear colorbar scaling.")
                        self._field_transform[f] = linear_transform

            font_size = self._font_properties.get_size()

            fig = None
            axes = None
            cax = None
            draw_colorbar = True
            draw_axes = True
            draw_frame = draw_axes
            if f in self.plots:
                draw_colorbar = self.plots[f]._draw_colorbar
                draw_axes = self.plots[f]._draw_axes
                draw_frame = self.plots[f]._draw_frame
                if self.plots[f].figure is not None:
                    fig = self.plots[f].figure
github yt-project / yt / yt / data_objects / particle_filters.py View on Github external
>>> yt.add_particle_filter("stars", function=_stars, filtered_type='all',
    ...                        requires=["particle_type"])

    >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
    >>> ds.add_particle_filter('stars')
    >>> ad = ds.all_data()
    >>> print (ad['stars', 'particle_mass'])
    [  1.68243760e+38   1.65690882e+38   1.65813321e+38 ...,   2.04238266e+38
       2.04523901e+38   2.04770938e+38] g

    """
    if requires is None:
        requires = []
    filter = ParticleFilter(name, function, requires, filtered_type)
    if filter_registry.get(name, None) is not None:
        mylog.warning('The %s particle filter already exists. Overriding.' % name)
    filter_registry[name] = filter
github yt-project / yt / yt / frontends / gamer / data_structures.py View on Github external
def _set_code_unit_attributes(self):
        if self.parameters['Opt__Unit']:
            # GAMER units are always in CGS
            setdefaultattr( self, 'length_unit', self.quan(self.parameters['Unit_L'], 'cm') )
            setdefaultattr( self, 'mass_unit',   self.quan(self.parameters['Unit_M'], 'g' ) )
            setdefaultattr( self, 'time_unit',   self.quan(self.parameters['Unit_T'], 's' ) )

        else:
            if len(self.units_override) == 0:
                mylog.warning("Cannot determine code units ==> " +
                              "Use units_override to specify the units")

            for unit, cgs in [("length", "cm"), ("time", "s"), ("mass", "g")]:
                setdefaultattr(self, "%s_unit"%unit, self.quan(1.0, cgs))

                if len(self.units_override) == 0:
                    mylog.warning("Assuming %s unit = 1.0 %s", unit, cgs)