The "foreign" Package

These routines convert between the Karma data format and foreign data formats.

Library: karma
Link With: -lkarma

Functions

foreign_aips1_read_dataset_namesGet the names of AIPS1 datasets in the directory catalogue.
foreign_aips1_readRead an AIPS dataset.
foreign_aips2_testTest if a directory is an AIPS++ Image file.
foreign_drao_read_dataset_namesGet the names of DRAO datasets in the directory catalogue.
foreign_drao_readRead a DRAO dataset.
foreign_filter_get_formatGet the filter format
foreign_filter_test_directory_datasetTest if a directory is a dataset.
foreign_filter_get_channelGet the channel for a filtered file.
foreign_filter_readRead a filtered file.
foreign_fits_read_headerRead a FITS header.
foreign_fits_readRead a FITS file.
foreign_fits_read_dataRead data in a FITS file.
foreign_fits_writeWrite a FITS file to a channel.
foreign_fits_write_iarrayWrite a FITS file to a channel.
foreign_fits_write_dataWrite data to a FITS file.
foreign_gipsy_testTest if a file is part of a GIPSY file set.
foreign_gipsy_read_headerRead a GIPSY file header.
foreign_gipsy_read_dataRead data in a GIPSY image file.
foreign_gipsy_readRead a GIPSY file set.
foreign_gipsy_writeWrite a GIPSY file.
foreign_gipsy_write_iarrayWrite a GIPSY file.
foreign_gipsy_write_headerWrite a GIPSY header.
foreign_guess_and_readGuess file type and read.
foreign_read_and_setupRead a file and perform some setup.
foreign_miriad_test2Test if a directory is a Miriad Image file.
foreign_miriad_read_headerRead a Miriad Image file header.
foreign_miriad_readRead a Miriad image file.
foreign_miriad_create_data_contextCreate a context suitable for reading Miriad Image data.
foreign_miriad_read_dataRead data in a Miriad Image file.
foreign_miriad_close_data_contextClose a KMiriadDataContext object.
foreign_miriad_read_historyRead the history component of a Miriad Image file.
foreign_miriad_writeWrite a Miriad Image file.
foreign_miriad_write_iarrayWrite a Miriad Image file.
foreign_guess_format_from_filenameAttempt to guess the format of a file by examining its filename.
foreign_pgm_readRead a colour image in PGM format from a channel.
foreign_pnm_read_typeRead the type of a PNM file.
foreign_pnm_readRead a PNM file.
foreign_ppm_readRead a colour image in PPM format from a channel.
foreign_ppm_writeWrite a colour image to a channel in PPM format
foreign_ppm_write_pseudoWrite a PseudoColor image to a channel in PPM format.
foreign_ppm_write_rgbWrite a TrueColor image to a channel in Sun rasterfile format
foreign_sunras_readRead an image in Sun rasterfile format from a channel.
foreign_sunras_writeWrite a colour image to a channel in Sun rasterfile format
foreign_sunras_write_pseudoWrite a PseudoColor image to a channel in Sun rasterfile format
foreign_sunras_write_rgbWrite a TrueColor image to a channel in Sun rasterfile format

Tables

foreign_ATT_FITS_READ_HEADERList of attributes for reading FITS headers
foreign_ATT_FITS_READ_DATAList of attributes for reading FITS data
foreign_ATT_GUESSList of attributes for guessing and reading data
foreign_ATT_MIRIAD_READ_HEADERList of attributes for reading Miriad Image headers
foreign_ATT_MIRIAD_READ_DATAList of attributes for reading Miriad Image data
foreign_ATT_MIRIAD_READList of attributes for reading Miriad Image files
foreign_ATT_GIPSY_READ_HEADERList of attributes for reading GIPSY Image headers
foreign_ATT_GIPSY_READ_DATAList of attributes for reading GIPSY Image data
foreign_ATT_GIPSY_READList of attributes for reading GIPSY Image files
foreign_TYPESList of foreign file types
foreign_ATT_PPM_WRITEList of attributes for writing PPM files
foreign_ATT_PPM_READList of attributes for reading PPM files
foreign_ATT_PGM_READList of attributes for reading PGM files
foreign_ATT_SUNRAS_READList of attributes for reading Sun Rasterfile files
foreign_ATT_SUNRAS_WRITEList of attributes for writing Sun Rasterfile files


Functions


EXPERIMENTAL FUNCTION: subject to change without notice

CONST char * foreign_aips1_read_dataset_names (CONST char *dirname, unsigned int *num_datasets)

This routine will read the "CAD000000.???" catalogue file in the specified directory and extracts the names of the datasets. The "AIPS_ID" environment variable should be set to your AIPS user ID.

Parameters:

Returns: A pointer to a buffer packed with dataset names. Each dataset name is separated by a '\0' character. The buffer is internally allocated and must not be freed. If no datasets are found NULL is returned.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

multi_array * foreign_aips1_read (CONST char *setname)

Read an AIPS dataset.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_aips2_test (CONST char *dirname, flag test_dir)

Test if a directory is an AIPS++ Image file.

Parameters:

Returns: TRUE if the directory is a AIPS++ Image file, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

CONST char * foreign_drao_read_dataset_names (CONST char *dirname, unsigned int *num_datasets)

This routine will read the "deffil.mad" catalogue file in the specified directory and extracts the names of the datasets.

Parameters:

Returns: A pointer to a buffer packed with dataset names. Each dataset name is separated by a '\0' character. The buffer is internally allocated and must not be freed. If no datasets are found NULL is returned.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

multi_array * foreign_drao_read (CONST char *setname)

Read a DRAO dataset.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

unsigned int foreign_filter_get_format (CONST char *filename)

Get the filter format

Parameters:

Returns: A value indicating the format of the file. The value FOREIGN_FILE_FORMAT_FILTER_KARMA is returned if a data filter to Karma for the file exists. The value FOREIGN_FILE_FORMAT_FILTER_FITS is returned if a data filter to FITS exists. Otherwise FOREIGN_FILE_FORMAT_UNKNOWN is returned.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_filter_test_directory_dataset (CONST char *dirname)

Test if a directory is a dataset.

Parameters:

Returns: TRUE if the directory is a dataset, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

Channel foreign_filter_get_channel (CONST char *filename)

Get the channel for a filtered file.

Parameters:

Returns: A channel object on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

multi_array * foreign_filter_read (CONST char *filename)

Read a filtered file.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


multi_array * foreign_fits_read_header (Channel channel, flag data_alloc, flag convert_int_to_float, flag sanitise, ...)

This routine will read the header of a FITS file from a channel. The data section is NOT read.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

multi_array * foreign_fits_read (CONST char *filename, flag convert_int_to_float, flag sanitise, ...)

Read a FITS file.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


flag foreign_fits_read_data (Channel channel, multi_array *multi_desc, char *data, uaddr num_values, ...)

This routine will read the data of a FITS file from a channel. The header section is NOT read.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag foreign_fits_write (Channel channel, multi_array *multi_desc, ...)

This routine will write a Karma data structure to a FITS file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BITPIX", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


flag foreign_fits_write_iarray (Channel channel, iarray array, ...)

This routine will write an Intelligent Array to a FITS file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BITPIX", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_fits_write_data (Channel channel, multi_array *multi_desc, CONST packet_desc *header_pack_desc, CONST char *header_packet, char *data, uaddr num_values, ...)

This routine will write the data section of a FITS file to a channel. The header section is NOT written.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag foreign_gipsy_test (CONST char *filename)

Test if a file is part of a GIPSY file set.

Parameters:

Returns: TRUE if the file is part of a GIPSY file set, else FALSE.
Multithreading Level: Unsafe


multi_array * foreign_gipsy_read_header (Channel channel, flag data_alloc, flag sanitise, ...)

This routine will read the header of a GIPSY file from a channel. The data section is NOT read.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL.
Multithreading Level: Unsafe


flag foreign_gipsy_read_data (Channel channel, multi_array *multi_desc, char *data, uaddr num_values, ...)

This routine will read the data of a GIPSY image file from a channel.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


multi_array * foreign_gipsy_read (CONST char *filename, flag sanitise, ...)

Read a GIPSY file set.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


flag foreign_gipsy_write (CONST char *basename, multi_array *multi_desc, ...)

This routine will write a Karma data structure to a GIPSY file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


flag foreign_gipsy_write_iarray (CONST char *basename, iarray array, ...)

This routine will write an Intelligent Array to a GIPSY file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BITPIX", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_gipsy_write_header (Channel channel, CONST packet_desc *header_pack_desc, CONST char *header_packet, ...)

Write a GIPSY header.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


multi_array * foreign_guess_and_read (CONST char *filename, unsigned int mmap_option, flag writable, unsigned int *ftype, ...)

This routine will attempt to guess the filetype of a file and in the file, converting to the Karma data format if possible.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_read_and_setup (CONST char *filename, unsigned int mmap_option, flag writable, unsigned int *ftype, flag inform, unsigned int num_dim, unsigned int preferred_type, flag force_type, iarray *array, double *min, double *max, flag discard_zero_range, KwcsAstro *ap)

This routine will attempt to guess the filetype of a file and in the file, converting to an Intelligent Array if possible. The routine then performs some simple checks and some other convenience functions.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_miriad_test2 (CONST char *dirname, flag test_dir)

Test if a directory is a Miriad Image file.

Parameters:

Returns: TRUE if the directory is a Miriad Image file, else FALSE.
Multithreading Level: Unsafe


multi_array * foreign_miriad_read_header (Channel channel, flag data_alloc, flag sanitise, ...)

This routine will read the header of a Miriad Image file from a channel. The data section is NOT read.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL.
Multithreading Level: Unsafe


multi_array * foreign_miriad_read (CONST char *dirname, flag sanitise, ...)

Read a Miriad image file.

Parameters:

Returns: A multi_array descriptor on success, else NULL.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KMiriadDataContext foreign_miriad_create_data_context (CONST char *dirname, unsigned int mmap_option, flag writable)

This routine will create a context suitable for reading Miriad Image data. The foreign_miriad_read_data routine may be used to read data sequentially from the context.

Parameters:

Returns: A KMiriadDataContext object on success, else NULL (indicating the image file could not be read).
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_miriad_read_data (KMiriadDataContext context, multi_array *multi_desc, char *data, uaddr num_values, ...)

This routine will read the data of a Miriad Image file from a KMiradDataContext object. The header section is NOT read.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void foreign_miriad_close_data_context (KMiriadDataContext context)

Close a KMiriadDataContext object.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_miriad_read_history (CONST char *dirname, multi_array *multi_desc)

Read the history component of a Miriad Image file.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag foreign_miriad_write (CONST char *dirname, multi_array *multi_desc, ...)

This routine will write a Karma data structure to a Miriad Image file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


flag foreign_miriad_write_iarray (CONST char *dirname, iarray array, ...)

This routine will write an Intelligent Array to a Miriad Image file. The routine will automatically generate essential keywords such as: "NAXIS", "NAXISn", "CTYPEn", "CRVALn", "CRPIXn", "CDELTn", "BITPIX", "BUNIT", "BSCALE" and "BZERO". Also, existing keywords in the data structure which do not conflict with the generated keywords are copied.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


unsigned int foreign_guess_format_from_filename (CONST char *filename)

Attempt to guess the format of a file by examining its filename.

Parameters:

Returns: A value indicating the format of the file. The value FOREIGN_FILE_FORMAT_KARMA is returned if the extension is ".kf". See foreign_TYPES for a list of possible values.
Multithreading Level: Unsafe


multi_array * foreign_pgm_read (Channel channel, ...)

Read a colour image in PGM format from a channel.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

unsigned int foreign_pnm_read_type (Channel channel, flag *binary)

Read the type of a PNM file.

Parameters:

Returns: The type of PNM file.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

multi_array * foreign_pnm_read (Channel channel)

Read a PNM file.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL.
Multithreading Level: Unsafe


multi_array * foreign_ppm_read (Channel channel, ...)

Read a colour image in PPM format from a channel.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL
Multithreading Level: Unsafe


flag foreign_ppm_write (Channel channel, multi_array *multi_desc, flag binary, ...)

Write a colour image to a channel in PPM format

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_ppm_write_pseudo (Channel channel, flag binary, CONST char *image, unsigned int type, uaddr *hoffsets, uaddr *voffsets, unsigned int inp_width, unsigned int inp_height, unsigned int out_width, unsigned int out_height, CONST unsigned short *cmap_reds, CONST unsigned short *cmap_greens, CONST unsigned short *cmap_blues, unsigned int cmap_size,unsigned int cmap_stride, double i_min, double i_max)

Write a PseudoColor image to a channel in PPM format.

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe.


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_ppm_write_rgb (Channel channel, flag binary, CONST unsigned char *image_red, CONST unsigned char *image_green, CONST unsigned char *image_blue, uaddr *hoffsets, uaddr *voffsets, unsigned int inp_width, unsigned int inp_height, unsigned int out_width, unsigned int out_height, CONST unsigned short *cmap_red, CONST unsigned short *cmap_green, CONST unsigned short *cmap_blue, unsigned int cmap_stride)

Write a TrueColor image to a channel in Sun rasterfile format

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe.


multi_array * foreign_sunras_read (Channel channel, ...)

Read an image in Sun rasterfile format from a channel.

Parameters:

Returns: A pointer to the multi_array data structure on success, else NULL
Multithreading Level: Unsafe


flag foreign_sunras_write (Channel channel, multi_array *multi_desc, ...)

Write a colour image to a channel in Sun rasterfile format

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe.


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_sunras_write_pseudo (Channel channel, CONST char *image, unsigned int type, uaddr *hoffsets, uaddr *voffsets, unsigned int width, unsigned int height, CONST unsigned short *cmap_reds, CONST unsigned short *cmap_greens, CONST unsigned short *cmap_blues, unsigned int cmap_size, unsigned int cmap_stride, double i_min, double i_max)

Write a PseudoColor image to a channel in Sun rasterfile format

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe.


EXPERIMENTAL FUNCTION: subject to change without notice

flag foreign_sunras_write_rgb (Channel channel, CONST unsigned char *image_red, CONST unsigned char *image_green, CONST unsigned char *image_blue, uaddr *hoffsets, uaddr *voffsets, unsigned int width, unsigned int height, CONST unsigned short *cmap_red, CONST unsigned short *cmap_green, CONST unsigned short *cmap_blue, unsigned int cmap_stride)

Write a TrueColor image to a channel in Sun rasterfile format

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe.


Tables


foreign_ATT_FITS_READ_HEADER

Name Type Meaning
FA_FITS_READ_HEADER_END End of varargs list
FA_FITS_READ_HEADER_ALLOC_TRUNC flag Allow truncated headers


foreign_ATT_FITS_READ_DATA

Name Type Meaning
FA_FITS_READ_DATA_END End of varargs list
FA_FITS_READ_DATA_NUM_BLANKS unsigned long * Number of blank values found
FA_FITS_READ_DATA_SKIP_BLOCKSflag Skip blocks


foreign_ATT_GUESS

Name Type Meaning
FA_GUESS_READ_END End of varargs list
FA_GUESS_READ_FITS_TO_FLOAT flag Convert FITS data to floating point


foreign_ATT_MIRIAD_READ_HEADER

Name Type Meaning
FA_MIRIAD_READ_HEADER_END End of varargs list


foreign_ATT_MIRIAD_READ_DATA

Name Type Meaning
FA_MIRIAD_READ_DATA_END End of varargs list
FA_MIRIAD_READ_DATA_NUM_BLANKS unsigned long * Number of blank values (includes masked values)
FA_MIRIAD_READ_DATA_NUM_MASKED unsigned long * Number of masked values
FA_MIRIAD_READ_DATA_SKIP_BLOCKSflag Skip blocks


foreign_ATT_MIRIAD_READ

Name Type Meaning
FA_MIRIAD_READ_END End of varargs list
FA_MIRIAD_READ_NUM_BLANKS unsigned long * Number of blank values (includes masked values)
FA_MIRIAD_READ_NUM_MASKED unsigned long * Number of masked values


foreign_ATT_GIPSY_READ_HEADER

Name Type Meaning
FA_GIPSY_READ_HEADER_END End of varargs list


foreign_ATT_GIPSY_READ_DATA

Name Type Meaning
FA_GIPSY_READ_DATA_END End of varargs list
FA_GIPSY_READ_DATA_NUM_BLANKS unsigned long * Number of blank values
FA_GIPSY_READ_DATA_SKIP_BLOCKSflag Skip blocks


foreign_ATT_GIPSY_READ

Name Type Meaning
FA_GIPSY_READ_END End of varargs list
FA_GIPSY_READ_NUM_BLANKS unsigned long * Number of blank values


foreign_TYPES

Name Meaning
FOREIGN_FILE_FORMAT_KARMA Karma file (native format)
FOREIGN_FILE_FORMAT_UNKNOWN Unknown format
FOREIGN_FILE_FORMAT_PPM Portable PixMap format (PPM)
FOREIGN_FILE_FORMAT_FITS Flexible Image Transport System (FITS)
FOREIGN_FILE_FORMAT_SUNRAS Sun Rasterfile
FOREIGN_FILE_FORMAT_MIRIAD Miriad Image file
FOREIGN_FILE_FORMAT_GIPSY GIPSY file
FOREIGN_FILE_FORMAT_PGM Portable Grey Map (PGM) file


foreign_ATT_PPM_WRITE

Name Type Meaning
FA_PPM_WRITE_END End of varargs list


foreign_ATT_PPM_READ

Name Type Meaning
FA_PPM_READ_END End of varargs list
FA_PPM_READ_BINARY flag If provided, do not read first line and use flag value


foreign_ATT_PGM_READ

Name Type Meaning
FA_PGM_READ_END End of varargs list


foreign_ATT_SUNRAS_READ

Name Type Meaning
FA_SUNRAS_READ_END End of varargs list


foreign_ATT_SUNRAS_WRITE

Name Type Meaning
FA_SUNRAS_WRITE_END End of varargs list
FA_SUNRAS_WRITE_NO_IMAGE flag * No image found in data structure


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services