def list_of_vars_in_e3sm_diags():
    """
    Get a list of all of the variables used in e3sm_diags.
    Open all of the *.cfg files located in acme_diags/acme_diags/driver/default_diags/
    and get all of the 'variables' parameters.
    """
    # Looks for these files in their installed location.
    pth = os.path.join(acme_diags.INSTALL_PATH)
    # The first '*' is the folder of the set, the second is the actual file.
    # Ex: {acme_diags.INSTALL_PATH}/lat_lon/lat_lon_model_vs_obs.cfg
    file_paths = [p for p in glob.glob(pth + '*/*.cfg')]

    # Get all of the 'variables' parameter from each file.
    vars_used = []
    parser = ACMEParser()
    parser.add_argument('path')  # Needed so the filename can be passed in.
    parameters = parser.get_other_parameters(files_to_open=file_paths,
                                             check_values=False)
    for p in parameters:
        vars_used.extend(p.variables)

    # We convert to a set because we only want one of each variable.
    return set(vars_used)
Example #2
0
    """
    #parser = argparse.ArgumentParser()
    #parser.add_argument("path")
    #path = parser.parse_args().path
    # path = DUMMY_FILE_PATH
    path = parser.parse_args().path
    print('Using the file: {}'.format(path))

    if not os.path.exists(path):
        msg = 'The file ({}) does not exist.'.format(path)
        raise RuntimeError(msg)
    with cdms2.open(path) as f:
        return f.variables.keys()

parser = ACMEParser()
parser.add_argument('path', default=DUMMY_FILE_PATH, nargs='?')

def list_of_vars_in_e3sm_diags():
    """
    Get a list of all of the variables used in e3sm_diags.
    Open all of the *.cfg files located in acme_diags/acme_diags/driver/default_diags/
    and get all of the 'variables' parameters.
    """

    # Get all of the 'variables' parameter from each file.
    vars_used = []
    #print('hi')
    #args = parser.parse_args()
    #print(dir(args))
    try:
        print('something')