# Path: pyradex/utils.py
# def united(qty, unit):
#     if isinstance(qty,u.Quantity):
#         return qty.to(unit)
#     else:
#         return qty*u.Unit(unit)
# 
# def uvalue(qty, unit):
#     return united(qty, unit).value


import numpy as np
import warnings
import os
        import despotic
from collections import defaultdict
from .utils import united,uvalue
from astropy import units as u
from astropy import constants
from astropy.table import Table,Column
        abundance: float
            The molecule's abundance relative to H (NOT H2 as is normally done!).
        tbackground: float
            Background radiation temperature (e.g., CMB)
        deltav: float
            The FWHM line width (really, the single-zone velocity width to
            scale the column density by: this is most sensibly interpreted as a
            velocity gradient (dv/dR))
        sigmaNT: float
            Nonthermal velocity dispersion
            (this is strictly ignored - deltav IS sigmant)
        datapath: str
            Path to the molecular data files
        """

        
        self.cloud = despotic.cloud()
        self.cloud.nH = float(np.sum([collider_densities[k]*2 if 'h2' in k.lower()
                                      else collider_densities[k]
                                      for k in collider_densities]))

        for k in collider_densities.keys():
            collider_densities[k.lower()] = collider_densities[k]

        if 'ph2' in collider_densities:
            self.cloud.comp.xpH2 = collider_densities['ph2'] / self.cloud.nH
        if 'oh2' in collider_densities:
            self.cloud.comp.xoH2 = collider_densities['oh2'] / self.cloud.nH

        self.cloud.Td = uvalue(temperature,u.K)

# Path: pyradex/utils.py
# def united(qty, unit):
#     if isinstance(qty,u.Quantity):
#         return qty.to(unit)
#     else:
#         return qty*u.Unit(unit)
# 
# def uvalue(qty, unit):
#     return united(qty, unit).value


# Path: pyradex/despotic_interface.py
import numpy as np
import warnings
import os
        import despotic
from collections import defaultdict
from .utils import united,uvalue
from astropy import units as u
from astropy import constants
from astropy.table import Table,Column

        abundance: float
            The molecule's abundance relative to H (NOT H2 as is normally done!).
        tbackground: float
            Background radiation temperature (e.g., CMB)
        deltav: float
            The FWHM line width (really, the single-zone velocity width to
            scale the column density by: this is most sensibly interpreted as a
            velocity gradient (dv/dR))
        sigmaNT: float
            Nonthermal velocity dispersion
            (this is strictly ignored - deltav IS sigmant)
        datapath: str
            Path to the molecular data files
        """

        
        self.cloud = despotic.cloud()
        self.cloud.nH = float(np.sum([collider_densities[k]*2 if 'h2' in k.lower()
                                      else collider_densities[k]
                                      for k in collider_densities]))

        for k in collider_densities.keys():
            collider_densities[k.lower()] = collider_densities[k]

        if 'ph2' in collider_densities:
            self.cloud.comp.xpH2 = collider_densities['ph2'] / self.cloud.nH
        if 'oh2' in collider_densities:
            self.cloud.comp.xoH2 = collider_densities['oh2'] / self.cloud.nH

        self.cloud.Td = uvalue(temperature,u.K)

        self.cloud.Tg = uvalue(temperature,u.K)