Ignore:
Timestamp:
Jun 16, 2025, 4:04:32 PM (4 days ago)
Author:
jbclement
Message:

Mars PCM:

  • Bug corrections for the Python script displaying variables in a NetCDF file regarding the dimensions + addition of options (for example to average over longitude).
  • Improvement for the Python script analyzing variables in a NetCDF file.

JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LMDZ.MARS/util/analyse_netcdf.py

    r3798 r3808  
    6262        data = variable[:]
    6363    except Exception as e:
    64         print(f"\nUnable to read variable '{name}': {e}")
     64        print(f"\nError: Unable to read variable '{name}': {e}")
    6565        return
    6666
     
    7676        print(f"  Dimensions: {dims}")
    7777        print(f"  Shape     : {shape}")
    78         print("  Entire variable is NaN or masked.")
     78        print("  \033[91mAnomaly: entire variable is NaN or masked!\033[0m")
    7979        return
    8080
     
    9696    print(f"  Mean value: {data_mean:>12.6e}")
    9797    if has_nan:
    98         print(f"  \033[91mContains NaN values!\033[0m")
     98        print(f"  \033[91mAnomaly: contains NaN values!\033[0m")
    9999    if has_negative:
    100         print(f"  \033[93mWarning: contains negative values!\033[0m")
     100        print(f"  \033[93mCaution: contains negative values!\033[0m")
    101101
    102102def analyze_netcdf_file(nc_path):
     
    123123        except Exception:
    124124            # If reading dtype fails, skip it
    125             print(f"\nSkipping variable with unknown type: {var_name}")
     125            print(f"\nWarning: Skipping variable with unknown type: {var_name}")
    126126            continue
    127127
     
    129129            analyze_variable(variable)
    130130        else:
    131             print(f"\nSkipping non-numeric variable: {var_name}")
     131            print(f"\nWarning: Skipping non-numeric variable: {var_name}")
    132132
    133133    ds.close()
     
    168168if __name__ == "__main__":
    169169    main()
    170 
Note: See TracChangeset for help on using the changeset viewer.