1 /*
2  * Copyright (c) 2011-2020, The University of Oxford
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright notice,
8  *    this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright notice,
10  *    this list of conditions and the following disclaimer in the documentation
11  *    and/or other materials provided with the distribution.
12  * 3. Neither the name of the University of Oxford nor the names of its
13  *    contributors may be used to endorse or promote products derived from this
14  *    software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef OSKAR_PRIVATE_STATION_H_
30 #define OSKAR_PRIVATE_STATION_H_
31 
32 #include <mem/oskar_mem.h>
33 #include <telescope/station/element/oskar_element.h>
34 
35 /* Forward declaration. */
36 struct oskar_Station;
37 
38 #ifndef OSKAR_STATION_TYPEDEF_
39 #define OSKAR_STATION_TYPEDEF_
40 typedef struct oskar_Station oskar_Station;
41 #endif /* OSKAR_STATION_TYPEDEF_ */
42 
43 struct oskar_Station
44 {
45     /* Private structure meta-data. */
46     int unique_id;                /* Unique ID for station within telescope. */
47     int precision;                /* Numerical precision of most arrays. */
48     int mem_location;             /* Memory location of most arrays. */
49 
50     /* Data common to all station types -------------------------------------*/
51     int station_type;             /* Type of the station (enumerator). */
52     int normalise_final_beam;     /* Flag to specify whether the station beam should be completely normalised. */
53     double offset_ecef[3];        /* Offset ECEF coordinates of the station, in metres. */
54     double lon_rad;               /* Geodetic east longitude of station, in radians. */
55     double lat_rad;               /* Geodetic latitude of station, in radians. */
56     double alt_metres;            /* Altitude of station above ellipsoid, in metres. */
57     double pm_x_rad;              /* Polar motion (x-component) in radians. */
58     double pm_y_rad;              /* Polar motion (y-component) in radians. */
59     double beam_lon_rad;          /* Longitude of beam phase centre, in radians. */
60     double beam_lat_rad;          /* Latitude of beam phase centre, in radians. */
61     int beam_coord_type;          /* Enumerator describing beam spherical coordinate type (from oskar_global.h). */
62     oskar_Mem* noise_freq_hz;     /* Frequency values, in Hz, at which noise RMS values are defined. */
63     oskar_Mem* noise_rms_jy;      /* RMS noise values, in Jy, as a function of frequency. */
64 
65     /* Data used only for Gaussian beam stations  ---------------------------*/
66     double gaussian_beam_fwhm_rad;   /* FWHM of Gaussian station beam, in degrees. */
67     double gaussian_beam_reference_freq_hz; /* Reference frequency of the FHWM, in Hz. */
68 
69     /* Data used only for aperture array stations ---------------------------*/
70     int identical_children;       /* True if all child stations are identical. */
71     int num_elements;             /* Number of antenna elements in the station (auto determined). */
72     int num_element_types;        /* Number of element types (this is the size of element_pattern array). */
73     int normalise_array_pattern;  /* True if the array pattern should be normalised by the number of antennas. */
74     int normalise_element_pattern;/* True if the element patterns should be normalised. */
75     int enable_array_pattern;     /* True if the array factor should be evaluated. */
76     int common_element_orientation; /* True if elements share a common orientation (auto determined). */
77     int common_pol_beams;         /* True if beams for both polarisations can be formed in the same way (auto determined). */
78     int swap_xy;                  /* True if the X and Y antennas should be swapped in the output. */
79     int array_is_3d;              /* True if array is 3-dimensional (auto determined; default false). */
80     int apply_element_errors;     /* True if element gain and phase errors should be applied (auto determined; default false). */
81     int apply_element_weight;     /* True if weights should be modified by user-supplied complex beamforming weights (auto determined; default false). */
82     unsigned int seed_time_variable_errors;       /* Seed for time variable errors. */
83     oskar_Mem* element_true_enu_metres[2][3];     /* True horizon element ENU coordinates, in metres. */
84     oskar_Mem* element_measured_enu_metres[2][3]; /* Measured horizon element ENU coordinates, in metres. */
85     oskar_Mem* element_gain[2];                   /* Element gain factor (default 1.0) */
86     oskar_Mem* element_gain_error[2];             /* Standard deviation of per-element time-variable gain factor (default 0.0) */
87     oskar_Mem* element_phase_offset_rad[2];       /* Element systematic phase offset, in radians (default 0.0) */
88     oskar_Mem* element_phase_error_rad[2];        /* Standard deviation of per-element time-variable phase, in radians (default 0.0) */
89     oskar_Mem* element_weight[2];                 /* Element complex weight (set to 1.0, 0.0 unless using apodisation). */
90     oskar_Mem* element_cable_length_error[2];     /* Element cable length error, in metres. */
91     oskar_Mem* element_euler_cpu[2][3];           /* Element Euler angles, guaranteed to be in CPU memory. */
92     oskar_Mem* element_types;     /* Integer array of element types (default 0). */
93     oskar_Mem* element_types_cpu; /* Integer array of element types guaranteed to be in CPU memory (default 0). */
94     oskar_Mem* element_mount_types_cpu; /* Char array of element mount types guaranteed to be in CPU memory. */
95     oskar_Station** child;        /* Array of child station handles (pointer is NULL if none). */
96     oskar_Element** element;      /* Array of element models per element type (pointer is NULL if there are child stations). */
97 
98     /* Data used only for aperture array stations with fixed beams. */
99     int num_permitted_beams;
100     oskar_Mem* permitted_beam_az_rad;
101     oskar_Mem* permitted_beam_el_rad;
102 };
103 
104 #endif /* OSKAR_PRIVATE_STATION_H_ */
105