Definition of the OLCI instrument.

    Source: Sentinel-3 OLCI Coverage
    https://sentinel.esa.int/web/sentinel/user-guides/sentinel-3-olci/coverage
972394
def olci(scans_nb, scan_points=None):
    

    if scan_points is None:
        scan_len = 4000  # samples per scan
        scan_points = np.arange(4000)
    else:
        scan_len = len(scan_points)
    # scan_rate = 0.044  # single scan, seconds
    scan_angle_west = 46.5  # swath, degrees
    scan_angle_east = -22.1  # swath, degrees
    # sampling_interval = 18e-3  # single view, seconds
    # build the olci instrument scan line angles
    scanline_angles = np.linspace(np.deg2rad(scan_angle_west),
                                  np.deg2rad(scan_angle_east), scan_len)
    inst = np.vstack((scanline_angles, np.zeros(scan_len,)))

    inst = np.tile(inst[:, np.newaxis, :], [1, np.int(scans_nb), 1])

    # building the corresponding times array
    # times = (np.tile(scan_points * 0.000025 + 0.0025415, [scans_nb, 1])
    #         + np.expand_dims(offset, 1))

    times = np.tile(np.zeros_like(scanline_angles), [np.int(scans_nb), 1])
    # if apply_offset:
    #     offset = np.arange(np.int(scans_nb)) * frequency
    #     times += np.expand_dims(offset, 1)

    return ScanGeometry(inst, times)
1058529
def _get_ethercat_interface_info(interface):
    '''
    
    '''
    base_information = _get_base_interface_info(interface)
    base_information['ethercat'] = {
        'masterid': _load_config(interface.name, ['MasterID'])['MasterID']
    }
    return base_information
609462
def _compute_fluxes(self):
        ''' '''
        self.emission = self._compute_emission()
        self.emission_sfc = self._compute_emission_sfc()
        fromspace = self._from_space()
        self.flux_down = self.trans.flux_down(fromspace, self.emission)
        self.flux_reflected_up = self.trans.flux_reflected_up(self.flux_down, self.albedo_sfc)
        # this ensure same dimensions as other fields
        self.flux_to_sfc = self.flux_down[..., -1, np.newaxis]
        self.flux_from_sfc = (self.emission_sfc +
                              self.flux_reflected_up[..., -1, np.newaxis])
        self.flux_up = self.trans.flux_up(self.flux_from_sfc,
                            self.emission + self.flux_reflected_up[...,0:-1])
        self.flux_net = self.flux_up - self.flux_down
        # absorbed radiation (flux convergence) in W / m**2 (per band)
        self.absorbed = np.diff(self.flux_net, axis=-1)
        self.absorbed_total = np.sum(self.absorbed, axis=-1)
        self.flux_to_space = self._compute_flux_top()
1183628
def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values):
        
        val_idx = 0

        # @TODO seems there is only a single field in each of these
        assert len(sensor_data_rec.field) == 1
        sensor_data_array = sensor_data_rec.field[0].content

        # there is probably not going to be a count in the def, it'll be in the data
        count = None
        count_text = sensor_data_array.elementCount.text
        if count_text:
            count = int(count_text.strip())

        if not count:
            count = int(rem_values[val_idx])
            val_idx += 1

        parsed = []

        for recnum in range(count):
            cur = []

            for f in sensor_data_array.elementType.field:
                cur_val = rem_values[val_idx]
                val_idx += 1

                m = Member(name=f.name, standard=f.content.definition)

                if hasattr(f.content, "uom"):
                    m["units"] = f.content.uom

                try:
                    m["value"] = float(cur_val)
                except ValueError:
                    m["value"] = cur_val

                if len(f.quality):
                    m["quality"] = []
                    for qual in f.quality:
                        cur_qual = rem_values[val_idx]
                        val_idx += 1

                        # @TODO check this against constraints
                        m["quality"].append(cur_qual)

                cur.append(m)

            parsed.append(cur)

        return parsed, val_idx
741536
public function definition() {
        global $CFG;

        $mform    =& $this->_form;

        $mform->addElement('header', 'setup', get_string('registration_options', 'lti'));

        // Tool Provider name.

        $strrequired = get_string('required');
        $mform->addElement('text', 'lti_registrationname', get_string('registrationname', 'lti'));
        $mform->setType('lti_registrationname', PARAM_TEXT);
        $mform->addHelpButton('lti_registrationname', 'registrationname', 'lti');
        $mform->addRule('lti_registrationname', $strrequired, 'required', null, 'client');

        // Registration URL.

        $mform->addElement('text', 'lti_registrationurl', get_string('registrationurl', 'lti'), array('size' => '64'));
        $mform->setType('lti_registrationurl', PARAM_URL);
        $mform->addHelpButton('lti_registrationurl', 'registrationurl', 'lti');
        $mform->addRule('lti_registrationurl', $strrequired, 'required', null, 'client');

        // LTI Capabilities.

        $options = array_keys(lti_get_capabilities());
        natcasesort($options);
        $attributes = array( 'multiple' => 1, 'size' => min(count($options), 10) );
        $mform->addElement('select', 'lti_capabilities', get_string('capabilities', 'lti'),
            array_combine($options, $options), $attributes);
        $mform->setType('lti_capabilities', PARAM_TEXT);
        $mform->addHelpButton('lti_capabilities', 'capabilities', 'lti');
        $mform->addRule('lti_capabilities', $strrequired, 'required', null, 'client');

        // LTI Services.

        $services = lti_get_services();
        $options = array();
        foreach ($services as $service) {
            $options[$service->get_id()] = $service->get_name();
        }
        $attributes = array( 'multiple' => 1, 'size' => min(count($options), 10) );
        $mform->addElement('select', 'lti_services', get_string('services', 'lti'), $options, $attributes);
        $mform->setType('lti_services', PARAM_TEXT);
        $mform->addHelpButton('lti_services', 'services', 'lti');
        $mform->addRule('lti_services', $strrequired, 'required', null, 'client');

        $mform->addElement('hidden', 'toolproxyid');
        $mform->setType('toolproxyid', PARAM_INT);

        $tab = optional_param('tab', '', PARAM_ALPHAEXT);
        $mform->addElement('hidden', 'tab', $tab);
        $mform->setType('tab', PARAM_ALPHAEXT);

        $courseid = optional_param('course', 1, PARAM_INT);
        $mform->addElement('hidden', 'course', $courseid);
        $mform->setType('course', PARAM_INT);

        // Add standard buttons, common to all modules.

        $this->add_action_buttons();
    }
1025919
function () {
            // CONUS Extent: (-124.848974, 24.396308) - (-66.885444, 49.384358)
            // TODO: Expand this extent to cover HI when the server NO_DATA value issue is resolved.
            TiledElevationCoverage.call(this, {
                coverageSector: new Sector(24.396308, 49.384358, -124.848974, -66.885444),
                resolution: 0.000092592592593,
                retrievalImageFormat: "application/bil16",
                minElevation: -11000,
                maxElevation: 8850,
                urlBuilder: new WmsUrlBuilder("https://worldwind26.arc.nasa.gov/elev", "USGS-NED", "", "1.3.0")
            });

            this.displayName = "USGS NED Earth Elevation Coverage";
        }
122036
private void calcBoundaries() {
		minBoundary.x = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.y = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.z = Double.MAX_VALUE;
		maxBoundary.z = Double.MIN_VALUE;
		xzRadiusMax = Double.MIN_VALUE;

		Point3d probe = new Point3d();

		for (Point3d[] list: subunits.getTraces()) {
			for (Point3d p: list) {
				probe.set(p);
				transformationMatrix.transform(probe);

				minBoundary.x = Math.min(minBoundary.x, probe.x);
				maxBoundary.x = Math.max(maxBoundary.x, probe.x);
				minBoundary.y = Math.min(minBoundary.y, probe.y);
				maxBoundary.y = Math.max(maxBoundary.y, probe.y);
				minBoundary.z = Math.min(minBoundary.z, probe.z);
				maxBoundary.z = Math.max(maxBoundary.z, probe.z);
				xzRadiusMax = Math.max(xzRadiusMax, Math.sqrt(probe.x*probe.x + probe.z * probe.z));
			}
		}
//		System.out.println("MinBoundary: " + minBoundary);
//		System.out.println("MaxBoundary: " + maxBoundary);
//		System.out.println("zxRadius: " + xzRadiusMax);
	}
1298968
function (options, send) {

	var clientPath = options.clientPath,
		coverage = options.coverage,
		parentId = options.parentId,
		configuration = options.configuration,
		globalConfig = options.globalConfig,
		decorators = options.decorators,
		decoratorPlugins = options.decoratorPlugins,

		ClientClass,
		clientInstance,

		coverageVar = '__preceptorCoverage__',
		instrumenter,
		transformer,
		globalCoverageConfig = globalConfig.coverage,
		coverageIncludes = globalCoverageConfig.includes || ['**/*.js'],
		coverageExcludes = globalCoverageConfig.excludes || ['**/node_modules/**', '**/test/**', '**/tests/**'];

	// Make global configuration available
	global.PRECEPTOR = {
		config: globalConfig
	};

	// Create client and run it
	ClientClass = require(clientPath);
	clientInstance = new ClientClass(decorators, decoratorPlugins, configuration);
	clientInstance.on('reportMessage', function (messageType, data) {
		send({
			type: "reportMessage",
			messageType: messageType,
			data: data
		});
	});

	// Is coverage requested?
	if (((coverage === undefined) || (coverage === true)) && globalCoverageConfig.active) {

		// Prepare coverage instrumentation
		instrumenter = new istanbul.Instrumenter({ coverageVariable: coverageVar, preserveComments: true });
		transformer = instrumenter.instrumentSync.bind(instrumenter);

		// Hook-up transformer for every new file loaded
		istanbul.hook.hookRequire(function (filePath) {
			var allowed = false;

			// Inclusion
			_.each(coverageIncludes, function (include) {
				allowed = allowed || minimatch(filePath, include);
			});

			if (allowed) {
				// Exclusion
				_.each(coverageExcludes, function (exclude) {
					allowed = allowed && !minimatch(filePath, exclude);
				});
			}

			return allowed;

		}, transformer, {});

		// Prepare variable
		global[coverageVar] = {};
	}

	// Run client
	clientInstance.run(parentId).then(function () {
		send({
			type: "completion",
			data: {
				success: true,
				coverage: global[coverageVar]
			}
		});
		global[coverageVar] = {}; // Reset

	}, function (err) {
		send({
			type: "completion",
			data: {
				success: false,
				coverage: global[coverageVar],
				context: err.stack
			}
		});
		global[coverageVar] = {}; // Reset
	});
}
557200
def available_datasets(self):
        """"""
        sensor = self.get_sensor(self['/attr/sensor'])
        nadir_resolution = self.get_nadir_resolution(sensor)
        for var_name, val in self.file_content.items():
            if isinstance(val, SDS):
                ds_info = {
                    'file_type': self.filetype_info['file_type'],
                    'resolution': nadir_resolution,
                }
                if self._is_polar():
                    ds_info['coordinates'] = ['longitude', 'latitude']
                yield DatasetID(name=var_name, resolution=nadir_resolution), ds_info
1112666
def sensor_names(self):
        
        res = self['/attr/instrument_name']
        if isinstance(res, np.ndarray):
            res = str(res.astype(str))
        res = [x.strip() for x in res.split(',')]
        if len(res) == 1:
            return res[0]
        return res
677026
function coverFile(srcFile) {
      var srcCode = grunt.file.read(srcFile);
      Instrument = require('coverjs').Instrument;

      try {
        return new Instrument(srcCode, {name: srcFile}).instrument();
      } catch (e) {
        grunt.log.error('File ' + srcFile + ' could not be instrumented.');
        grunt.fatal(e, 3);
      }
    }
591246
def _parse_bands(self, band_input):
        
        all_bands = AwsConstants.S2_L1C_BANDS if self.data_source is DataSource.SENTINEL2_L1C else \
            AwsConstants.S2_L2A_BANDS

        if band_input is None:
            return all_bands
        if isinstance(band_input, str):
            band_list = band_input.split(',')
        elif isinstance(band_input, list):
            band_list = band_input.copy()
        else:
            raise ValueError('bands parameter must be a list or a string')
        band_list = [band.strip().split('.')[0] for band in band_list]
        band_list = [band for band in band_list if band != '']
        if not set(band_list) <= set(all_bands):
            raise ValueError('bands {} must be a subset of {}'.format(band_list, all_bands))
        return band_list
79667
def get_obss_scan_params(_, data):
    
    answers = {
        'passive dwell': (data[1] << 8) | data[0],
        'active dwell': (data[3] << 8) | data[2],
        'channel width trigger scan interval': (data[5] << 8) | data[4],
        'scan passive total per channel': (data[7] << 8) | data[6],
        'scan active total per channel': (data[9] << 8) | data[8],
        'BSS width channel transition delay factor': (data[11] << 8) | data[10],
        'OBSS Scan Activity Threshold': ((data[13] << 8) | data[12]) / 100.0
    }
    return answers
352903
def ascat(scan_nb, scan_points=None):
    

    if scan_points is None:
        scan_len = 42  # samples per scan
        scan_points = np.arange(42)
    else:
        scan_len = len(scan_points)

    scan_angle_inner = -25.0  # swath, degrees
    scan_angle_outer = -53.0  # swath, degrees
    scan_rate = 3.74747474747  # single scan, seconds
    if scan_len < 2:
        raise ValueError("Need at least two scan points!")

    sampling_interval = scan_rate / float(np.max(scan_points) + 1)

    # build the Metop/ascat instrument scan line angles
    scanline_angles_one = np.linspace(-np.deg2rad(scan_angle_outer),
                                      -np.deg2rad(scan_angle_inner), 21)
    scanline_angles_two = np.linspace(np.deg2rad(scan_angle_inner),
                                      np.deg2rad(scan_angle_outer), 21)

    scan_angles = np.concatenate(
        [scanline_angles_one, scanline_angles_two])[scan_points]

    inst = np.vstack((scan_angles, np.zeros(scan_len * 1,)))
    inst = np.tile(inst[:, np.newaxis, :], [1, np.int(scan_nb), 1])

    # building the corresponding times array
    offset = np.arange(scan_nb) * scan_rate

    times = (np.tile(scan_points * sampling_interval,
                     [np.int(scan_nb), 1]) + np.expand_dims(offset, 1))

    return ScanGeometry(inst, times)
255793
def envelope(self, instrument):
        
        def envelopeFunc(mz):
            if isinstance(mz, numbers.Number):
                return ims.spectrum_envelope(self.ptr, instrument.ptr, mz)
            mzs = _cffi_buffer(mz, 'd')
            n = len(mz)
            buf = _cffi_buffer(n, 'f')
            ret = ims.spectrum_envelope_plot(self.ptr, instrument.ptr, mzs.ptr, n, buf.ptr)
            if ret < 0:
                _raise_ims_exception()
            return buf.python_data()

        return envelopeFunc
172946
def uvw(self, context):
        

        # Hacky access of private member
        cube = context._cube

        # Create antenna1 source context
        a1_actual = cube.array("antenna1", reify=True)
        a1_ctx = SourceContext("antenna1", cube, context.cfg,
            context.iter_args, cube.array("antenna1"),
            a1_actual.shape, a1_actual.dtype)

        # Create antenna2 source context
        a2_actual = cube.array("antenna2", reify=True)
        a2_ctx = SourceContext("antenna2", cube, context.cfg,
            context.iter_args, cube.array("antenna2"),
            a2_actual.shape, a2_actual.dtype)

        # Get antenna1 and antenna2 data
        ant1 = self.antenna1(a1_ctx).ravel()
        ant2 = self.antenna2(a2_ctx).ravel()

        # Obtain per baseline UVW data
        lrow, urow = MS.uvw_row_extents(context)
        uvw = self._manager.ordered_uvw_table.getcol(MS.UVW,
                                                startrow=lrow,
                                                nrow=urow-lrow)

        # Perform the per-antenna UVW decomposition
        ntime, nbl = context.dim_extent_size('ntime', 'nbl')
        na = context.dim_global_size('na')
        chunks = np.repeat(nbl, ntime).astype(ant1.dtype)

        auvw = mbu.antenna_uvw(uvw, ant1, ant2, chunks, nr_of_antenna=na)

        return auvw.reshape(context.shape).astype(context.dtype)
1069914
def compile_with_instrumentation(self,
                                     container: Container,
                                     verbose: bool = False
                                     ) -> CompilationOutcome:
        
        bug = self.__installation.bugs[container.bug]
        bug.compiler.clean(self, container, verbose=verbose) # TODO port
        return bug.compiler.compile_with_coverage_instrumentation(self,
                                                                  container,
                                                                  verbose=verbose)