@@ -430,3 +430,97 @@ call {py:func}`polaris.model_step.make_graph_file()` to produce a graph file
430430from an MPAS mesh file. Optionally, you can provide the name of an MPAS field
431431on cells in the mesh file that gives different weight to different cells
432432(`weight_field`) in the partitioning process.
433+
434+ # # Detailed Documentation: polaris.namelist, polaris.streams, and polaris.yaml
435+
436+ # ## `polaris.namelist`
437+
438+ This module provides utilities for reading, parsing, updating, and writing
439+ MPAS-style namelist files. It is used to manage namelist options for E3SM
440+ components.
441+
442+ **Key Functions:**
443+ - `parse_replacements(package, namelist)` : Reads a namelist file from a
444+ package and returns a dictionary of option replacements.
445+ - `ingest(defaults_filename)` : Reads a full namelist file and returns a nested
446+ dictionary of records and options.
447+ - `replace(namelist, replacements)` : Applies replacements to a namelist
448+ dictionary.
449+ - `write(namelist, filename)` : Writes a nested namelist dictionary to a file.
450+
451+ **Example Usage:**
452+ ` ` ` python
453+ from polaris import namelist
454+
455+ replacements = namelist.parse_replacements('my_package', 'namelist.forward')
456+ namelist_dict = namelist.ingest('namelist.defaults')
457+ updated = namelist.replace(namelist_dict, replacements)
458+ namelist.write(updated, 'namelist.input')
459+ ` ` `
460+
461+ # ## `polaris.streams`
462+
463+ This module provides tools for reading, updating, and writing MPAS streams XML
464+ files, including support for Jinja2 templating.
465+
466+ **Key Functions:**
467+ - `read(package, streams_filename, tree=None, replacements=None)` : Reads a
468+ streams XML file (optionally as a Jinja2 template) and returns an XML tree.
469+ - `write(streams, out_filename)` : Writes a streams XML tree to a file.
470+ - `update_tree(tree, new_tree)` : Updates an existing streams tree with new
471+ streams.
472+ - `set_default_io_type(tree, io_type='pnetcdf,cdf5')` : Sets the `io_type`
473+ attribute for output streams if not already set.
474+
475+ **Example Usage:**
476+ ` ` ` python
477+ from polaris import streams
478+
479+ tree = streams.read('my_package', 'streams.forward')
480+ streams.write(tree, 'streams.xml')
481+ ` ` `
482+
483+ # ## `polaris.yaml`
484+
485+ This module provides a class for reading, writing, and updating YAML
486+ configuration files for E3SM components, including support for Jinja2
487+ templating and conversion between YAML and MPAS namelist/streams formats.
488+
489+ **Key Classes and Functions:**
490+ - `PolarisYaml` : Main class for managing YAML configs.
491+ - `PolarisYaml.read(filename, package=None, replacements=None, ...)` : Reads
492+ a YAML file (optionally as a Jinja2 template).
493+ - `PolarisYaml.update(configs=None, options=None, quiet=True)` : Updates the
494+ config with new options.
495+ - `PolarisYaml.write(filename)` : Writes the config to a YAML file.
496+ - `mpas_namelist_and_streams_to_yaml(...)` : Converts MPAS namelist and streams
497+ files to a YAML config.
498+
499+ **Example Usage:**
500+ ` ` ` python
501+ from polaris.yaml import PolarisYaml
502+
503+ yaml_cfg = PolarisYaml.read('config.yaml')
504+ yaml_cfg.update(options={'config_dt': '00:10:00'})
505+ yaml_cfg.write('updated_config.yaml')
506+ ` ` `
507+
508+ **See also:**
509+ Refer to the API documentation for each module for a full list of functions
510+ and classes :
511+ * {py:func}`polaris.namelist.parse_replacements`
512+ * {py:func}`polaris.namelist.ingest`
513+ * {py:func}`polaris.namelist.replace`
514+ * {py:func}`polaris.namelist.write`
515+ * {py:func}`polaris.streams.read`
516+ * {py:func}`polaris.streams.write`
517+ * {py:func}`polaris.streams.update_defaults`
518+ * {py:func}`polaris.streams.update_tree`
519+ * {py:func}`polaris.streams.set_default_io_type`
520+ * {py:class}`polaris.yaml.PolarisYaml`
521+ * {py:meth}`polaris.yaml.PolarisYaml.read`
522+ * {py:meth}`polaris.yaml.PolarisYaml.update`
523+ * {py:meth}`polaris.yaml.PolarisYaml.write`
524+ * {py:func}`polaris.yaml.mpas_namelist_and_streams_to_yaml`
525+ * {py:func}`polaris.yaml.yaml_to_mpas_streams`
526+ * {py:func}`polaris.yaml.main_mpas_to_yaml`
0 commit comments