Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect DataFrame in a common API to ExoJAX #256

Closed
HajimeKawahara opened this issue May 12, 2022 · 14 comments
Closed

How to connect DataFrame in a common API to ExoJAX #256

HajimeKawahara opened this issue May 12, 2022 · 14 comments
Milestone

Comments

@HajimeKawahara
Copy link
Owner

HajimeKawahara commented May 12, 2022

@HajimeKawahara
Copy link
Owner Author

HajimeKawahara commented May 13, 2022

Let's discuss in the discussion?
@erwanp @ykawashima @chonma0ctopus

@HajimeKawahara
Copy link
Owner Author

@erwanp

Hello! Sorry for long silence. I have been busy the past few months as I moved from University of Tokyo to JAXA/ISAS (change my institution in your slide). Anyway, I manage to start a common API issue.

Currently, I am trying to use fetch_exomol as an interface
(here)

        dataframe = fetch_exomol(self.simple_molecule_name,
                                 database=self.database,
                                 local_databases=self.path)

But I am wondering how we should call pf (partition function) info. Sofar we used exomolapi.read_pf in exojax.
(here)

        # load pf
        pf = exomolapi.read_pf(self.pf_file)
        self.gQT = jnp.array(pf['QT'].to_numpy())  # grid QT
        self.T_gQT = jnp.array(pf['T'].to_numpy())  # T forgrid QT
        self.QTref = np.array(self.QT_interp(Tref))
        self.QTtyp = np.array(self.QT_interp(self.Ttyp))

I'd like to hear your opinion.

@HajimeKawahara HajimeKawahara changed the title Conversion to DataFrame in a common API How to connect DataFrame in a common API to ExoJAX Jul 16, 2022
@HajimeKawahara HajimeKawahara added this to the v1.2 milestone Jul 16, 2022
@erwanp
Copy link
Collaborator

erwanp commented Jul 17, 2022

Hello, congrats on the move ! Our lab worked with Kazuhisa Fujita-sama at JAXA, if you happen to meet him.

--

Side note, I think you shouldn't use fetch_exomol() directly. It includes some RADIS specific features, such as storing databases in ~/.radisdb or registering them in radis.json (which is useful, but should not be required by Exojax). Also, it renames columns in a RADIS-specific format.
Instead, I suggest you use the underlying class from the common API, MdbExomol

--

For Partition Functions, I used a RADIS-specific mdb.to_partition_function_tabulator() function, which generates PartFuncExoMol, basically just an interpolator which returns np.interp(T, self.T_range, self.Q_range)

I think you should keep on using the ExoJax syntax you showed above. T_gQT, qGT can be retrieved from the MdbExoMol object :

  mdb = MdbExomol(
      local_path,
      molecule=molecule,
      name=databank_name,
      local_databases=local_databases,
      nurange=[
          load_wavenum_min if load_wavenum_min is not None else 0.0,
          load_wavenum_max if load_wavenum_max is not None else np.inf,
      ],
      engine=engine,
      cache=cache,
      skip_optional_data=skip_optional_data,
  )
#...
T_gQT, gQT = mdb.T_gQT, mdb.gQT

(link to common-api branch)

@HajimeKawahara
Copy link
Owner Author

Hello @erwanp,

Thanks a lot. I see. Then, first, I will try to wrap radis.api.exomol.MdbExomol in exojax.spec.api.MdbExomol.
I think, in near future, maybe we should directly call radis.api.exomol.MdbExomol but now, I feel the wrapping is more safe.

@erwanp
Copy link
Collaborator

erwanp commented Jul 17, 2022

Yes, agreed. These API will take some time before they reach their final form. Even after you call radis.api.exomol.MdbExomol I'd suggest to Inherit() and Subclass the Radis class so you can easily override anything at anytime if needed (without having to require any RADIS update).

So in exojax/spec/api

from radis.api.exomol import MdbExomol 

class MdbExoMol(MdbExomol):
    ... 

@HajimeKawahara
Copy link
Owner Author

@erwanp

I think I managed to connect radis/api/exomolapi.py (working at common-api branch) to exojax/spec/api.py (working at radisapi branch) for ExoMol.

tests in ExoJAX

  • exojax/tests/integration/moldb

tests in radis

  • radis/radis/test/io

Before I move on HITEMP, I'd like you to make sure this is the right direction. I found, for HITEMP unlike ExoMol, MdbExomol like class does not exist in radis yet. Instead, I found HITEMPDatabaseManager. What are your thoughts on how to connect radis HITEMP API to ExoJAX?

@erwanp
Copy link
Collaborator

erwanp commented Jul 28, 2022

Hello ! HITEMPDatabaseManager inherits from DatabaseManager, similarly to MdBExomol. Therefore, HITEMPDatabaseManager will play the same role as MdBExomol in the API.

So it should be fairly easy to just duplicate the changes, unless you see a problem I missed ?

@HajimeKawahara
Copy link
Owner Author

OK, then, I will try to implement it the same way as mdbExomol 😃 Thanks!

@HajimeKawahara
Copy link
Owner Author

@erwanp
Hello! I have a question on hapi in radis. It looks that the installation of radis automatically installs hapi. Is it correct? If true, how does it work?

@HajimeKawahara
Copy link
Owner Author

@erwanp Sorry to keep asking questions. What is the main reason for implementing hitranapi and hitempapi separately? Maybe data format?

@erwanp
Copy link
Collaborator

erwanp commented Aug 22, 2022

Many parts are common, but the download is different.
And Hitran has more columns than the default ones, we currently have a project radis/radis#495 to automatically include the broadening coefficients of non-air species. This is a Hitran only feature.

@erwanp
Copy link
Collaborator

erwanp commented Aug 22, 2022

@erwanp Hello! I have a question on hapi in radis. It looks that the installation of radis automatically installs hapi. Is it correct? If true, how does it work?

Hapi is pip installable. The pip package name is hitran-api
https://github.com/radis/radis/blob/develop/environment.yml

@HajimeKawahara
Copy link
Owner Author

Hapi is pip installable. The pip package name is hitran-api

Thanks! Oh really. I did not notice that.

Many parts are common, but the download is different.
And Hitran has more columns than the default ones, we currently have a project radis/radis#495 to automatically include the broadening coefficients of non-air species. This is a Hitran only feature.

I see. So, it's presumably better to have separate moldbs in ExoJAX too.

@HajimeKawahara
Copy link
Owner Author

#309 removed the old moldb. So, now ExoJAX officially determined to use radis.api as I/O of ExoMol, HITRAN, and HITEMP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants