<commit_before>import numpy as np
try:
    import xarray as xr
except ImportError:
    raise ImportError(
        "Xarray output in Pyqg requires the Xarray package, which is not installed on your system. " 
        "Please install Xarray in order to activate this feature. "
        "Instructions at http://xarray.pydata.org/en/stable/getting-started-guide/installing.html#instructions"
    )
    
from pyqg.errors import DiagnosticNotFilledError

# Define dict for variable dimensions
spatial_dims = ('time','lev','y','x')
spectral_dims = ('time','lev','l','k')
dim_database = {
    'q': spatial_dims,
    'u': spatial_dims,
    'v': spatial_dims,
    'ufull': spatial_dims,
    'vfull': spatial_dims, 
    'qh': spectral_dims,
    'uh': spectral_dims,
    'vh': spectral_dims,
    'ph': spectral_dims, 
    'dqhdt': spectral_dims, 
    'Ubg': ('lev'),
    'Qy': ('lev'),
}

# dict for variable dimensions
var_attr_database = {
    'q':     { 'units': 's^-1',      'long_name': 'potential vorticity in real space',},
    'u':     { 'units': 'm s^-1',    'long_name': 'zonal velocity anomaly',},
    'v':     { 'units': 'm s^-1',    'long_name': 'meridional velocity anomaly',},
    'ufull': { 'units': 'm s^-1',    'long_name': 'zonal full velocities in real space',},
    'vfull': { 'units': 'm s^-1',    'long_name': 'meridional full velocities in real space',},
    'qh':    { 'units': 's^-1',      'long_name': 'potential vorticity in spectral space',},
    'uh':    { 'units': 'm s^-1',    'long_name': 'zonal velocity anomaly in spectral space',},
    'vh':    { 'units': 'm s^-1',    'long_name': 'meridional velocity anomaly in spectral space',},
    'ph':    { 'units': 'm^2 s^-1',  'long_name': 'streamfunction in spectral space',},
    'p':     { 'units': 'm^2 s^-1',  'long_name': 'streamfunction in real space',},
    'Ubg':   { 'units': 'm s^-1',    'long_name': 'background zonal velocity',},
    'Qy':    { 'units': 's^-1 m^-1', 'long_name': 'background potential vorticity gradient',} , 
    'dqhdt': { 'units': 's^-2',      'long_name': 'previous partial derivative of potential vorticity wrt. time in spectral space',} , 
    'dqdt':  { 'units': 's^-2',      'long_name': 'previous partial derivative of potential vorticity wrt. time in real space',} , 
}

# dict for variables to convert back from spectral to spatial
vars_to_invert = {
    'dqhdt': 'dqdt',
    'ph': 'p'
}

# dict for coordinate dimensions
coord_database = {
    'time': ('time'),
    'lev': ('lev'),
    'lev_mid': ('lev_mid'),
    'x': ('x'),
    'y': ('y'),
    'l': ('l'),
    'k': ('k'),
}

# dict for coordinate attributes 
coord_attr_database = {
    'time': {'long_name': 'model time', 'units': 's',},
    'lev': {'long_name': 'vertical levels',},
    'lev_mid': {'long_name': 'vertical level interface',},<commit_msg>Fix order<commit_after>import numpy as np
try:
    import xarray as xr
except ImportError:
    raise ImportError(
        "Xarray output in Pyqg requires the Xarray package, which is not installed on your system. " 
        "Please install Xarray in order to activate this feature. "
        "Instructions at http://xarray.pydata.org/en/stable/getting-started-guide/installing.html#instructions"
    )
    
from pyqg.errors import DiagnosticNotFilledError

# Define dict for variable dimensions
spatial_dims = ('time','lev','y','x')
spectral_dims = ('time','lev','l','k')
dim_database = {
    'q': spatial_dims,
    'u': spatial_dims,
    'v': spatial_dims,
    'ufull': spatial_dims,
    'vfull': spatial_dims, 
    'qh': spectral_dims,
    'uh': spectral_dims,
    'vh': spectral_dims,
    'ph': spectral_dims, 
    'dqhdt': spectral_dims, 
    'Ubg': ('lev'),
    'Qy': ('lev'),
}

# dict for variable dimensions
var_attr_database = {
    'q':     { 'units': 's^-1',      'long_name': 'potential vorticity in real space',},
    'u':     { 'units': 'm s^-1',    'long_name': 'zonal velocity anomaly',},
    'v':     { 'units': 'm s^-1',    'long_name': 'meridional velocity anomaly',},
    'ufull': { 'units': 'm s^-1',    'long_name': 'zonal full velocities in real space',},
    'vfull': { 'units': 'm s^-1',    'long_name': 'meridional full velocities in real space',},
    'qh':    { 'units': 's^-1',      'long_name': 'potential vorticity in spectral space',},
    'uh':    { 'units': 'm s^-1',    'long_name': 'zonal velocity anomaly in spectral space',},
    'vh':    { 'units': 'm s^-1',    'long_name': 'meridional velocity anomaly in spectral space',},
    'ph':    { 'units': 'm^2 s^-1',  'long_name': 'streamfunction in spectral space',},
    'p':     { 'units': 'm^2 s^-1',  'long_name': 'streamfunction in real space',},
    'Ubg':   { 'units': 'm s^-1',    'long_name': 'background zonal velocity',},
    'Qy':    { 'units': 'm^-1 s^-1', 'long_name': 'background potential vorticity gradient',} , 
    'dqhdt': { 'units': 's^-2',      'long_name': 'previous partial derivative of potential vorticity wrt. time in spectral space',} , 
    'dqdt':  { 'units': 's^-2',      'long_name': 'previous partial derivative of potential vorticity wrt. time in real space',} , 
}

# dict for variables to convert back from spectral to spatial
vars_to_invert = {
    'dqhdt': 'dqdt',
    'ph': 'p'
}

# dict for coordinate dimensions
coord_database = {
    'time': ('time'),
    'lev': ('lev'),
    'lev_mid': ('lev_mid'),
    'x': ('x'),
    'y': ('y'),
    'l': ('l'),
    'k': ('k'),
}

# dict for coordinate attributes 
coord_attr_database = {
    'time': {'long_name': 'model time', 'units': 's',},
    'lev': {'long_name': 'vertical levels',},
    'lev_mid': {'long_name': 'vertical level interface',},
{'fraction_non_alphanumeric': 0.18763326226012794, 'fraction_numerical': 0.006041222459132907, 'mean_word_length': 3.4322834645669293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1640876', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1917, 'n_words': 560}