Exemple #1
0
def test_can_read_all_files_in_magicc_dir(dir_to_check):
    cannot_read = []
    ignored = []
    for file_to_read in listdir(dir_to_check):
        try:
            if file_to_read.endswith(
                (".exe", ".mod", ".mat", ".m", ".BINOUT")):
                ignored.append(file_to_read)
            elif file_to_read.endswith(".CFG"):
                read_cfg_file(join(dir_to_check, file_to_read))
            elif file_to_read.endswith("PARAMETERS.OUT"):
                read_cfg_file(join(dir_to_check, file_to_read))
            else:
                mdata = MAGICCData()
                mdata.read(dir_to_check, file_to_read)
        except:
            cannot_read.append(file_to_read)

    print_summary(cannot_read, ignored, dir_to_check)
"""A simple script that can be used to read and write a file to see the effects of the formatting without having to always stop and debug tests
"""

import os
from os.path import join, expanduser

from pymagicc.io import MAGICCData

here = os.path.dirname(os.path.abspath(__file__))
fpath = join(here, "..", "pymagicc", "MAGICC6", "run")
fname = "RCP26.SCEN"

mi_writer = MAGICCData()
mi_writer.read(filepath=fpath, filename=fname)

mi_writer.write(join(expanduser("~"), fname))