Convert pressure array from Pa to hPa (if needed).
974413
def to_hpa(arr):
    """"""
    if np.max(np.abs(arr)) > 1200.:
        warn_msg = "Conversion applied: Pa -> hPa to array: {}".format(arr)
        logging.debug(warn_msg)
        return arr / 100.
    return arr
127516
def _update_dPrxy(self):
        """"""
        super(ExpCM_empirical_phi_divpressure, self)._update_dPrxy()
        if 'omega2' in self.freeparams:
            with scipy.errstate(divide='raise', under='raise', over='raise',
                            invalid='ignore'):
                scipy.copyto(self.dPrxy['omega2'], -self.ln_piAx_piAy_beta
                        * self.Qxy * self.omega /
                        (1 - self.piAx_piAy_beta), where=CODON_NONSYN)
            scipy.copyto(self.dPrxy['omega2'], self.Qxy * self.omega,
                       where=scipy.logical_and(CODON_NONSYN, scipy.fabs(1 -
                       self.piAx_piAy_beta) < ALMOST_ZERO))
            for r in range(self.nsites):
                self.dPrxy['omega2'][r] *= self.deltar[r]
            _fill_diagonals(self.dPrxy['omega2'], self._diag_indices)
889295
def pfull_from_ps(bk, pk, ps, pfull_coord):
    """"""
    return to_pfull_from_phalf(phalf_from_ps(bk, pk, ps), pfull_coord)
57117
def mach2tas(M, h):
    
    a = vsound(h)
    tas = M * a
    return tas
766300
def re_pipe(FlowRate, Diam, Nu):
    """"""
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"],
                   [Nu, ">0", "Nu"])
    return (4 * FlowRate) / (np.pi * Diam * Nu)
982854
def bp_to_aap (bp):
    """"""

    ap1, ap2 = bp
    if ap1 < 0:
        raise ValueError ('first antpol %d is negative' % ap1)
    if ap2 < 0:
        raise ValueError ('second antpol %d is negative' % ap2)

    pol = _fpol_to_pol[((ap1 & 0x7) << 4) + (ap2 & 0x7)]
    if pol == 0xFF:
        raise ValueError ('no CASA polarization code for pairing '
                          '%c-%c' % (fpol_names[ap1 & 0x7],
                                     fpol_names[ap2 & 0x7]))

    return ap1 >> 3, ap2 >> 3, pol
418094
def _insert_lcl_level(pressure, temperature, lcl_pressure):
    """"""
    interp_temp = interpolate_1d(lcl_pressure, pressure, temperature)

    # Pressure needs to be increasing for searchsorted, so flip it and then convert
    # the index back to the original array
    loc = pressure.size - pressure[::-1].searchsorted(lcl_pressure)
    return np.insert(temperature.m, loc, interp_temp.m) * temperature.units
684546
def to_array(self, channels=2):
        """"""
        return np.linspace(self.volume, self.volume,
            self.duration * channels).reshape(self.duration, channels)
178410
def _handlePressure(self, d):
        
        press = d['press']
        if press != '////':
            press = float(press.replace('O', '0'))
            if d['unit']:
                if d['unit'] == 'A' or (d['unit2'] and d['unit2'] == 'INS'):
                    self.press = CustomPressure(press / 100, 'IN')
                elif d['unit'] == 'SLP':
                    if press < 500:
                        press = press / 10 + 1000
                    else:
                        press = press / 10 + 900
                    self.press = CustomPressure(press)
                    self._remarks.append("sea-level pressure %.1fhPa" % press)
                else:
                    self.press = CustomPressure(press)
            elif press > 2500:
                self.press = CustomPressure(press / 100, 'IN')
            else:
                self.press = CustomPressure(press)
1126894
def _lbdvrpmllpmbb(self,*args,**kwargs):
        """"""
        obs, ro, vo= self._parse_radec_kwargs(kwargs,dontpop=True)
        X,Y,Z,vX,vY,vZ= self._XYZvxvyvz(*args,**kwargs)
        bad_indx= (X == 0.)*(Y == 0.)*(Z == 0.)
        if True in bad_indx:
            X[bad_indx]+= ro/10000.
        return coords.rectgal_to_sphergal(X,Y,Z,vX,vY,vZ,degree=True)
298533
def decode_hparams(overrides=""):
  """"""
  hp = hparam.HParams(
      save_images=False,
      log_results=True,
      extra_length=100,
      min_length_ratio=0.0,
      batch_size=0,
      beam_size=4,
      alpha=0.6,
      eos_penalty=0.0,
      block_size=0,
      guess_and_check_top_k=0,
      guess_and_check_epsilon=-1,
      insertion_parallel=False,
      return_beams=False,
      write_beam_scores=False,
      max_input_size=-1,
      identity_output=False,
      num_samples=-1,  # Number of examples to decode.
      delimiter="\n",
      decode_to_file="",  # str. Prefix for filename to write decodings to.
      decode_reference="",  # str. Filename to read references from.
      decode_in_memory=False,
      # How much decode should wait for the next checkpoint
      decode_timeout_mins=240,
      summaries_log_dir="decode",  # Directory to write hook summaries.
      shards=1,    # How many shards of data to decode (treating 1 as None).
      shard_id=0,  # Which shard are we decoding if more than 1 above.
      shards_start_offset=0,  # Number of the first shard to decode.
      shard_google_format=False,  # If True use Google shard naming format.
      num_decodes=1,  # Number of times to go over the dataset.
      force_decode_length=False,
      display_decoded_images=False,
      # Multi-problem decoding task id.
      multiproblem_task_id=-1,
      # Used for video decoding.
      frames_per_second=10,
      skip_eos_postprocess=False,
      # Creates a blue/red border covering border_percent of the frame.
      border_percent=2,
      # Maximum number of videos displayed.
      # number of videos displayed = max_display_outputs * max_display_decodes
      max_display_outputs=10,
      max_display_decodes=5,
      # Used in computation of VGG feature based video metrics.
      # Set this to be the path to a trained VGG ckpt to output
      # useful metrics.
      vgg_ckpt_path="",
      # Used for MLPerf compliance logging.
      mlperf_decode_step=0.0,
      mlperf_threshold=25.0,
      mlperf_success=False)
  hp.parse(overrides)
  return hp
326689
def _psi(self,m):
        """"""
        return 2.*self.a2*(1./(1.+m/self.a)+numpy.log(m/(m+self.a)))
393075
def __getBarFC(pressure):
    """"""
    if pressure is None:
        return 0
    press = __to_float1(pressure)
    if press < 974:
        return 1
    if press < 990:
        return 2
    if press < 1002:
        return 3
    if press < 1010:
        return 4
    if press < 1022:
        return 5
    if press < 1035:
        return 6
    return 7
1005023
def psi_to_pi(psi, axis=None):
    
    if axis is None:
        if psi.ndim == 1:
            K = psi.size + 1
            pi = np.zeros(K)

            # Set pi[1..K-1]
            stick = 1.0
            for k in range(K-1):
                pi[k] = logistic(psi[k]) * stick
                stick -= pi[k]

            # Set the last output
            pi[-1] = stick
            # DEBUG
            assert np.allclose(pi.sum(), 1.0)

        elif psi.ndim == 2:
            M, Km1 = psi.shape
            K = Km1 + 1
            pi = np.zeros((M,K))

            # Set pi[1..K-1]
            stick = np.ones(M)
            for k in range(K-1):
                pi[:,k] = logistic(psi[:,k]) * stick
                stick -= pi[:,k]

            # Set the last output
            pi[:,-1] = stick

            # DEBUG
            assert np.allclose(pi.sum(axis=1), 1.0)

        else:
            raise ValueError("psi must be 1 or 2D")
    else:
        K = psi.shape[axis] + 1
        pi = np.zeros([psi.shape[dim] if dim != axis else K for dim in range(psi.ndim)])
        stick = np.ones(psi.shape[:axis] + psi.shape[axis+1:])
        for k in range(K-1):
            inds = [slice(None) if dim != axis else k for dim in range(psi.ndim)]
            pi[inds] = logistic(psi[inds]) * stick
            stick -= pi[inds]
        pi[[slice(None) if dim != axis else -1 for dim in range(psi.ndim)]] = stick
        assert np.allclose(pi.sum(axis=axis), 1.)

    return pi
1131832
def TP0(dv, u):
    ''''''
    return np.linalg.norm(np.array(dv)) + np.linalg.norm(np.array(u))
26930
def pad_to_power2(data, axis = None, mode="constant"):
    
    if axis is None:
        axis = list(range(data.ndim))

    if np.all([_is_power2(n) for i, n in enumerate(data.shape) if i in axis]):
        return data
    else:
        return pad_to_shape(data,[(_next_power_of_2(n) if i in axis else n) for i,n in enumerate(data.shape)], mode)
1328626
def _hp_ars(x,params):
    """"""
    mO, sO2= params
    return -(x-mO)/sO2+1./x