How to use the phoebe.units.conversions.convert function in phoebe

To help you get started, we’ve selected a few phoebe 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 phoebe-project / phoebe2 / phoebe / backend / plotting.py View on Github external
flux = conversions.convert(from_unit, y_unit, flux,
                                       passband=dep['passband'])
        from_unit = y_unit
    else:
        y_unit = from_unit
    axes_units[1] = conversions.unit2texlabel(from_unit)
    axes_labels[1] = 'Flux'
    
    # plot observations
    artists = []
    if not phased:
        # XAXIS
        from_unit = obs.get_parameter('time').get_unit()
        if x_unit is not None:
            time = conversions.convert(from_unit, x_unit, time)
            period = conversions.convert(from_unit, x_unit, period)
            from_unit = x_unit
        else:
            x_unit = from_unit
        axes_units[0] = conversions.unit2texlabel(from_unit)
        axes_labels[0] = 'Time'
        
        for n in range(repeat+1):
            if n>=1:
                kwargs['label'] = '_nolegend_'
                
            if not simulate:
                p = ax.errorbar(time+n*period, flux, **kwargs)
                artists.append(p)
    else:
        time = ((time-t0) % period) / period
        # XAXIS
github phoebe-project / phoebe2 / phoebe / backend / plotting.py View on Github external
else:
        y_unit = from_unit
    axes_units[1] = conversions.unit2texlabel(from_unit)
    axes_labels[1] = 'Flux'
            
    # Plot model: either in phase or in time.
    artists = []
    if not phased:
        # XAXIS
        if obs is not None:
            from_unit = obs.get_parameter('time').get_unit()
        else:
            from_unit = 'JD'
        if x_unit is not None:
            time = conversions.convert(from_unit, x_unit, time)
            period = conversions.convert(from_unit, x_unit, period)
            from_unit = x_unit
        else:
            x_unit = from_unit
        axes_units[0] = conversions.unit2texlabel(from_unit)
        axes_labels[0] = 'Time'
        
        for n in range(repeat+1):
            if n>=1:
                kwargs['label'] = '_nolegend_'
            
            if not simulate:
                p, = ax.plot(time+n*period, flux, *args, **kwargs)
                artists.append(p)
    else:
        time = ((time-t0) % period) / period
        # XAXIS
github phoebe-project / phoebe2 / phoebe / backend / plotting.py View on Github external
if x_quantity == 'baseline':
        x = np.sqrt(syn['ucoord']**2 + syn['vcoord']**2)
        if x_unit is None:
            x_unit = 'm'
        x = conversions.convert('m', x_unit, x)
    elif x_quantity == 'frequency':
        eff_wave= conversions.convert('AA', 'm', np.asarray(syn['eff_wave']))
        x = np.sqrt(syn['ucoord']**2 + syn['vcoord']**2)/eff_wave
        if x_unit is None:
            x_unit = 'cy/rad'
    else:
        x = syn[x_quantity]
        x_unit_o = syn.get_parameter(x_quantity).get_unit()
        if x_unit is None:
            x_unit = x_unit_o
        x = conversions.convert(x_unit_o, x_unit, x)
    
    # Collect Y-data for plotting
    if y_quantity == 'vis':
        y = np.sqrt(syn['vis2'])
    else:
        y = syn[y_quantity]
    
    if y_unit is None:
        y_unit = ''
    
    if not simulate:
        artists = []
        p = ax.plot(x, y, *args, **kwargs)
        artists.append(p)
    
    translation = dict(vis2='Squared visibility', vis='Visibility')
github phoebe-project / phoebe2 / phoebe / backend / plotting.py View on Github external
time = obs['time']
    etv = obs['etv']
    sigm = obs['sigma']
    
    #-- get the period to repeat the ETV with
    if period is None:
        period = max(time)
    
    #-- plot model
    artists = []
    if not phased:
        for n in range(repeat+1):
            if errorbars:
                p = ax.errorbar(time+n*period,conversions.convert('d','s',etv),yerr=sigm,**kwargs)
            else:
                p = ax.plot(time+n*period, conversions.convert('d','s',etv), **kwargs)
            artists.append(p)
    else:
        time = (time % period) / period
        # need to sort by time (if using lines)
        o = time.argsort()
        time, etv = time[o], etv[o]
        for n in range(repeat+1):
            if errorbars:
                p = ax.errorbar(time+n,conversions.convert('d','s',etv),yerr=sigm,**kwargs)
            else:
                p = ax.plot(time+n,conversions.convert('d','s',etv),**kwargs)
            artists.append(p)

    if loaded: obs.unload()

    # TODO: make these automated
github phoebe-project / phoebe2 / phoebe / backend / plotting.py View on Github external
axes_units[0] = conversions.unit2texlabel(from_unit)
        axes_labels[0] = 'Time'
        
        for n in range(repeat+1):
            if n>=1:
                kwargs['label'] = '_nolegend_'
            if not simulate:
                p = ax.errorbar(time+n*period, rv, **kwargs)
                artists.append(p)
    else:
        time = ((time-t0) % period) / period
        # XAXIS
        from_unit = 'cy'
        period = 1.0
        if x_unit is not None:
            time = conversions.convert(from_unit, x_unit, time)
            period = conversions.convert(from_unit, x_unit, period)
            from_unit = x_unit
        else:
            x_unit = from_unit
            
        axes_units[0] = conversions.unit2texlabel(from_unit)
        axes_labels[0] = 'Phase'
        
        # need to sort by time (if using lines, it looks ugly)
        o = time.argsort()
        time, rv = time[o], rv[o]
        if has_error:
            kwargs['yerr'] = kwargs['yerr'][o]
        
        for n in range(repeat+1):
            if n>=1: