GNU Astronomy Utilities


Previous: , Up: Library data container   [Contents][Index]


10.3.5.4 Copying datasets

The functions in this section describes Gnuastro’s facilities to copy a given dataset into another. The new dataset can have a different type (including a string), it can be already allocated (in which case only the values will be written into it). In all these cases, if the input dataset is a tile, only the data within the tile are copied.

In many of the functions here, it is possible to copy the dataset to a new numeric data type (see Numeric data types. In such cases, Gnuastro’s library is going to use the native conversion by C. So if you are converting to a smaller type, it is up to you to make sure that the values fit into the output type.

Function:
gal_data_t *
gal_data_copy (gal_data_t *in)

Return a new dataset that is a copy of in, the main meta-data of the input is also copied into the output.

Function:
gal_data_t *
gal_data_copy_to_new_type (gal_data_t *in, uint8_t newtype)

Return a copy of the dataset in, converted to newtype, see Library data types (type.h) for Gnuastro library’s type identifiers. The returned dataset will have all meta-data accept their type equal to the input’s metadata.

Function:
gal_data_t *
gal_data_copy_to_new_type_free (gal_data_t *in, uint8_t newtype)

Return a copy of the dataset in that is converted to newtype and free the input dataset. See Library data types (type.h) for Gnuastro library’s type identifiers. The returned dataset will have all meta-data, except their type, equal to the input’s metadata. This function is similar to gal_data_copy_to_new_type, except that it will free the input dataset.

Function:
void
gal_data_copy_to_allocated (gal_data_t *in, gal_data_t *out)

Copy the contents of the array in in into the already allocated array in out. The types of the input and output may be different, type conversion will be done internally. When in->size != out->size this function will behave as follows:

out->size < in->size

This function won’t re-allocate the necessary space, it will abort with an error, so please check before calling this function.

out->size > in->size

This function will write the values in out->size and out->dsize from the same values of in. So if you want to use a pre-allocated space/dataset multiple times with varying input sizes, be sure to reset out->size before every call to this function.

Function:
gal_data_t *
gal_data_copy_string_to_number (char *string)

Read string into the smallest type that can store the value (see Numeric data types). This function is just a wrapper for the gal_type_string_to_number, but will put the value into a single-element dataset.


Previous: , Up: Library data container   [Contents][Index]