# Buggy code
def __init__(
    self,
    latitude_of_projection_origin=0.0,
    longitude_of_projection_origin=0.0,
    false_easting=0.0,
    false_northing=0.0,
    ellipsoid=None,
):
    """
    Constructs a Lambert Azimuthal Equal Area coord system.

    Kwargs:

        * latitude_of_projection_origin
                True latitude of planar origin in degrees. Defaults to 0.

        * longitude_of_projection_origin
                True longitude of planar origin in degrees. Defaults to 0.

        * false_easting
                X offset from planar origin in metres. Defaults to 0.

        * false_northing
                Y offset from planar origin in metres. Defaults to 0.

        * ellipsoid
                :class:`GeogCS` defining the ellipsoid.

    """
    #: True latitude of planar origin in degrees.
    self.latitude_of_projection_origin = latitude_of_projection_origin
    #: True longitude of planar origin in degrees.
    self.longitude_of_projection_origin = longitude_of_projection_origin
    #: X offset from planar origin in metres.
    self.false_easting = false_easting
    #: Y offset from planar origin in metres.
    self.false_northing = false_northing
    #: Ellipsoid definition.
    self.ellipsoid = ellipsoid


# Traceback (TypeError)
iris.__version__
Out[25]: '2.3.0'

In [26]: c =  iris.load_cube('/our/own/local/directory/hierarchy/snw_EUR-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN63_v1_day_19790101-19801231.nc')

In [27]: c.coord('projection_x_coordinate')
Out[27]:
DimCoord(array([   0. ,   12.5,   25. ,   37.5,   50. ,   62.5,   75. ,   87.5,
100. ,  112.5,  125. ,  137.5,  150. ,  162.5,  175. ,  187.5,
##   8>< snip    8>< snip
5500. , 5512.5, 5525. , 5537.5, 5550. , 5562.5, 5575. , 5587.5,
5600. , 5612.5, 5625. , 5637.5, 5650. ]), standard_name='projection_x_coordinate', units=Unit('km'), long_name='x coordinate of projection', var_name='x', coord_system=LambertConformal(central_lat=49.5, central_lon=10.5, false_easting=None, false_northing=None, secant_latitudes=(49.5,), ellipsoid=None))

In [28]: iris.save(c,'c.nc')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-4160b1a355b0> in <module>
----> 1 iris.save(c,'c.nc')

~/.conda/envs/climix-devel-3/lib/python3.8/site-packages/iris/io/__init__.py in save(source, target, saver, **kwargs)
406     # Single cube?
407     if isinstance(source, iris.cube.Cube):
--> 408         saver(source, target, **kwargs)
409
410     # CubeList or sequence of cubes?

~/.conda/envs/climix-devel-3/lib/python3.8/site-packages/iris/fileformats/netcdf.py in save(cube, filename, netcdf_format, local_keys, unlimited_dimensions, zlib, complevel, shuffle, fletcher32, contiguous, chunksizes, endian, least_significant_digit, packing, fill_value)
2386         # Iterate through the cubelist.
2387         for cube, packspec, fill_value in zip(cubes, packspecs, fill_values):
-> 2388             sman.write(cube, local_keys, unlimited_dimensions, zlib, complevel,
2389                        shuffle, fletcher32, contiguous, chunksizes, endian,
2390                        least_significant_digit, packing=packspec,

~/.conda/envs/climix-devel-3/lib/python3.8/site-packages/iris/fileformats/netcdf.py in write(self, cube, local_keys, unlimited_dimensions, zlib, complevel, shuffle, fletcher32, contiguous, chunksizes, endian, least_significant_digit, packing, fill_value)
981
982         # Create the associated cube CF-netCDF data variable.
--> 983         cf_var_cube = self._create_cf_data_variable(
984             cube, dimension_names, local_keys, zlib=zlib, complevel=complevel,
985             shuffle=shuffle, fletcher32=fletcher32, contiguous=contiguous,

~/.conda/envs/climix-devel-3/lib/python3.8/site-packages/iris/fileformats/netcdf.py in _create_cf_data_variable(self, cube, dimension_names, local_keys, packing, fill_value, **kwargs)
2131
2132         # Create the CF-netCDF grid mapping.
-> 2133         self._create_cf_grid_mapping(cube, cf_var)
2134
2135         return cf_var

~/.conda/envs/climix-devel-3/lib/python3.8/site-packages/iris/fileformats/netcdf.py in _create_cf_grid_mapping(self, cube, cf_var_cube)
1848                     cf_var_grid.latitude_of_projection_origin = cs.central_lat
1849                     cf_var_grid.longitude_of_central_meridian = cs.central_lon
-> 1850                     cf_var_grid.false_easting = cs.false_easting
1851                     cf_var_grid.false_northing = cs.false_northing
1852

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.__setattr__()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.setncattr()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4._set_att()

TypeError: illegal data type for attribute b'false_easting', must be one of dict_keys(['S1', 'i1', 'u1', 'i2', 'u2', 'i4', 'u4', 'i8', 'u8', 'f4', 'f8']), got O


In [29]: !ncdump -h /our/own/local/directory/hierarchy/snw_EUR-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN63_v1_day_19790101-19801231.nc
netcdf snw_EUR-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN63_v1_day_19790101-19801231 {
dimensions:
y = 453 ;
x = 453 ;
nvertex = 4 ;
time = UNLIMITED ; // (731 currently)
axis_nbounds = 2 ;
variables:
double bounds_nav_lon(y, x, nvertex) ;
double bounds_nav_lat(y, x, nvertex) ;
double time(time) ;
time:axis = "T" ;
time:standard_name = "time" ;
time:long_name = "Time axis" ;
time:calendar = "gregorian" ;
time:units = "days since 1949-01-01 00:00:00" ;
time:time_origin = "1949-01-01 00:00:00" ;
time:bounds = "time_bounds" ;
double time_bounds(time, axis_nbounds) ;
float snw(time, y, x) ;
snw:standard_name = "surface_snow_amount" ;
snw:long_name = "Surface Snow Amount" ;
snw:units = "kg m-2" ;
snw:online_operation = "average" ;
snw:interval_operation = "450 s" ;
snw:interval_write = "1 d" ;
snw:cell_methods = "time: mean" ;
snw:_FillValue = 1.e+20f ;
snw:missing_value = 1.e+20f ;
snw:coordinates = "lon lat" ;
snw:grid_mapping = "Lambert_Conformal" ;
double lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "Longitude" ;
lon:units = "degrees_east" ;
lon:bounds = "bounds_nav_lon" ;
double lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "Latitude" ;
lat:units = "degrees_north" ;
lat:bounds = "bounds_nav_lat" ;
char Lambert_Conformal ;
Lambert_Conformal:latitude_of_projection_origin = 49.5f ;
Lambert_Conformal:standard_parallel = 49.5f ;
Lambert_Conformal:longitude_of_central_meridian = 10.5f ;
Lambert_Conformal:grid_mapping_name = "lambert_conformal_conic" ;
double x(x) ;
x:units = "km" ;
x:long_name = "x coordinate of projection" ;
x:standard_name = "projection_x_coordinate" ;
x:axis = "X" ;
double y(y) ;
y:units = "km" ;
y:long_name = "y coordinate of projection" ;
y:standard_name = "projection_y_coordinate" ;
y:axis = "Y" ;

// global attributes:
:description = "Created by xios" ;
:title = "Created by xios" ;
:Conventions = "CF-1.6" ;
:creation_date = "2018-09-28T16:13:44Z" ;
:name = "EUR-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN63_v1_day" ;
:institute_id = "CNRM" ;
:institution = "CNRM (Centre National de Recherches Meteorologiques, Toulouse 31057, France)" ;
:model_id = "CNRM-ALADIN63" ;
:experiment_id = "evaluation" ;
:experiment = "Evaluation run with reanalysis forcing" ;
:contact = "contact.aladin-cordex@meteo.fr" ;
:product = "output" ;
:Convention = "CF-1.6" ;
:driving_model_id = "ECMWF-ERAINT" ;
:driving_model_ensemble_member = "r1i1p1" ;
:driving_experiment_name = "evaluation" ;
:driving_experiment = "ERA-INTERIM, evaluation, r1i1p1" ;
:rcm_version_id = "v1" ;
:project_id = "CORDEX" ;
:CORDEX_domain = "EUR-11" ;
:references = "http://www.umr-cnrm.fr/spip.php?article125&amp;lang=en" ;
:comment = "CORDEX Europe EUR-11 CNRM-ALADIN 6.3 L91 ECMWF-ERAINT: EUC12v63-1.100. Reference : Daniel M., Lemonsu A., Déqué M., Somot S., Alias A., Masson V. (2018) Benefits of explicit urban parametrization in regional climate modelling to study climate and city interactions. Climate Dynamics, 1-20, doi:10.1007/s00382-018-4289-x" ;
:frequency = "day" ;
:tracking_id = "hdl:21.14103/0efca508-2ffb-420b-8093-fffe58a7ae75" ;
}

# Fixed code
def __init__(
    self,
    latitude_of_projection_origin=None,
    longitude_of_projection_origin=None,
    false_easting=None,
    false_northing=None,
    ellipsoid=None,
):
    """
    Constructs a Lambert Azimuthal Equal Area coord system.

    Kwargs:

    * latitude_of_projection_origin:
        True latitude of planar origin in degrees. Defaults to 0.0 .

    * longitude_of_projection_origin:
        True longitude of planar origin in degrees. Defaults to 0.0 .

    * false_easting:
            X offset from planar origin in metres. Defaults to 0.0 .

    * false_northing:
            Y offset from planar origin in metres. Defaults to 0.0 .

    * ellipsoid (:class:`GeogCS`):
        If given, defines the ellipsoid.

    """
    #: True latitude of planar origin in degrees.
    self.latitude_of_projection_origin = _arg_default(latitude_of_projection_origin, 0)

    #: True longitude of planar origin in degrees.
    self.longitude_of_projection_origin = _arg_default(
        longitude_of_projection_origin, 0
    )

    #: X offset from planar origin in metres.
    self.false_easting = _arg_default(false_easting, 0)

    #: Y offset from planar origin in metres.
    self.false_northing = _arg_default(false_northing, 0)

    #: Ellipsoid definition (:class:`GeogCS` or None).
    self.ellipsoid = ellipsoid