coconut_tools.create_dat

Module for generating EUHFORIA-compatible solar wind boundary files from COCONUT outputs.

This module processes CFmesh plasma simulation output, interpolates it onto a heliospheric boundary grid, and formats the result into .dat files usable as input for heliospheric simulations like EUHFORIA.

Main tasks: - Load and interpret CFmesh geometry and field data, - Interpolate plasma and magnetic field variables onto a spherical grid, - Optionally rotate the grid to match Carrington/Stonyhurst frames, - Save results in the required EUHFORIA .dat format.

Typically used as a post-processing step after a COCONUT coronal simulation.

Functions

create_boundary_fromcfmesh(inputfile, time, ...)

Creates a boundary file by interpolating CFmesh volume data onto a spherical grid.

extract_number(file_name)

Extracts the numerical index from a CFmesh filename.

readstruct(lines)

Reads the structure of a CFmesh file.

rotation(input_dat, output_dat, angle_degrees)

Rotates the longitude data in a boundary file and adjusts selected fields accordingly.

rsun_to_m(x)

Convert a distance expressed in solar radii to meters.

coconut_tools.create_dat.create_boundary_fromcfmesh(inputfile, time, rad_out, nb_th, nb_phi, eps, output_dat, full_output=True)[source]

Creates a boundary file by interpolating CFmesh volume data onto a spherical grid.

Parameters:
  • inputfile (str) – Path to the input CFmesh file.

  • time (str) – Timestamp string in ISO format.

  • rad_out (float) – Target radius for the boundary. ; (m, 0.1 AU by default)

  • nb_th (int) – Number of colatitude grid points.

  • nb_phi (int) – Number of longitude grid points.

  • eps (float) – Small angle offset to avoid poles.

  • output_dat (str) – Output file path.

  • full_output (bool) – Whether to include all variables or a reduced subset.

Return type:

None

coconut_tools.create_dat.extract_number(file_name)[source]

Extracts the numerical index from a CFmesh filename.

Parameters:

file_name (str) – The filename to extract the number from.

Returns:

Extracted number or 0 if not found.

Return type:

int

coconut_tools.create_dat.readstruct(lines)[source]

Reads the structure of a CFmesh file.

Parameters:

lines (List[str]) – Lines of the CFmesh file.

Returns:

Indices of node, state, element, outlet, number of elements, number of !END markers, and list of comments.

Return type:

Tuple[int, int, int, int, int, int, List[Tuple[int, str]]]

coconut_tools.create_dat.rotation(input_dat, output_dat, angle_degrees, full_output=True, rad_out=21.5)[source]

Rotates the longitude data in a boundary file and adjusts selected fields accordingly.

Parameters:
  • input_dat (str) – Path to the input data file.

  • output_dat (str) – Path to the output data file.

  • angle_degrees (float) – Rotation angle in degrees.

  • full_output (bool) – Whether to include all variables (True) or only vr, number_density, temperature, Br (False).

  • rad_out (float)

Return type:

None

coconut_tools.create_dat.rsun_to_m(x)[source]

Convert a distance expressed in solar radii to meters.

The conversion assumes 1 astronomical unit equals 215 solar radii, which implies 1 Rsun = 149597870700 / 215 meters.

Parameters:

x (float) – Distance in solar radii.

Returns:

Distance in meters.

Return type:

float