Skip to content

Commit

Permalink
add convert too
Browse files Browse the repository at this point in the history
  • Loading branch information
sigrimm committed Oct 12, 2020
1 parent c75205c commit c539352
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/helios_k/hitemp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ the HELIOS-K ``param.dat`` file under ``pathToData``.


References
~~~~~~~~
~~~~~~~~~~

HITEMP gives an example how to cite their work:

Expand Down
25 changes: 25 additions & 0 deletions docs/helios_k/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ It contains nu and K(nu), where nu are the wavenumbers and K(nu) is the
full opacity function. When the ``PFile`` option is used, then the files
contain also the values of T and P.

| This files are written by using the option:
- doStoreFullK = 1

.. _out_<name>.bin:

``Out_<name>.bin``
------------------
Binary output file, it contains K(nu), where nu are the wavenumbers and K(nu) is the
full opacity function. The wavenumbers are not contained in the output files, and
have to be calculated manually by using the wavenumber resolution, and file line index.
The opacities are stored in a single precision floating point binary format.

| This files are written by using the option:
- doStoreFullK = 2


``Convert Out_<name>.dat to Out_<name>.bin files``
--------------------------------------------------
Output files in the text format ``*.dat`` can be converted into binary ``*.bin`` files
with the script ``DATtoBIN.py`` in the ``/tools`` directory.

Use for example ``python3 DATtoBIN.py -n Out_i`` to convert the file ``Out_i.dat`` to ``Out_i.bin``.

.. _out_<name>_bin.dat:

``Out_<name>_bin.dat``
Expand Down
14 changes: 7 additions & 7 deletions docs/helios_k/plinth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ When using cutted line wing profiles in combination with a continuum and
far wing background cross section, it can be necessary to remove the plinth
of each transition line, since this can be already included in the backround.

|See for example:
|Ptashnik, Igor & McPheat, Robert & Shine, Keith & Smith, Kevin & Williams, Robert. (2012). Water vapour foreign-continuum absorption in near-infrared windows from laboratory measurements. Philosophical transactions. Series A, Mathematical, physical, and engineering sciences. 370. 2557-77. 10.1098/rsta.2011.0218.
|or
|S.A. Clough, F.X. Kneizys, R.W. Davies,
| See for example:
| Ptashnik, Igor & McPheat, Robert & Shine, Keith & Smith, Kevin & Williams, Robert. (2012). Water vapour foreign-continuum absorption in near-infrared windows from laboratory measurements. Philosophical transactions. Series A, Mathematical, physical, and engineering sciences. 370. 2557-77. 10.1098/rsta.2011.0218.
| or
| S.A. Clough, F.X. Kneizys, R.W. Davies,
Line shape and the water vapor continuum,
Atmospheric Research,
Volume 23, Issues 3–4,
Expand All @@ -19,9 +20,8 @@ https://doi.org/10.1016/0169-8095(89)90020-3.


| Removing the plinth from the opacities can be done with the `removePlinth` option
in the `param.dat` file. The hight of the plinth is defines as the value of the
line profile at the cutting length. And example is shown in :numref:`fiplinth`.

| in the `param.dat` file. The hight of the plinth is defines as the value of the
| line profile at the cutting length. And example is shown in :numref:`fiplinth`.
| Relevant parameters for this example:
Expand Down
46 changes: 46 additions & 0 deletions tools/DATtoBIN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#this script converts a HELIOS-K opacity *.dat file to a binary opacity *.bin file

#Date: October 2020
#Author: Simon Grimm

import numpy as np
import struct
import argparse


def main(filename):


datFilename = '%s.dat' % filename
binFilename = '%s.bin' % filename

binFile = open(binFilename, "wb")

nu, K = np.loadtxt(datFilename, unpack=True)

for i in range(len(nu)):
kb = struct.pack('f', K[i])
binFile.write(kb)

#print(nu[i], K[i])



binFile.close()


if __name__ == '__main__':


parser = argparse.ArgumentParser()

parser.add_argument('-n', '--name', type=str,
help='file name', default = 'Out_i')


args = parser.parse_args()

print("Convert %s.dat to %s.bin" % (args.name, args.name))

main(args.name)

0 comments on commit c539352

Please sign in to comment.