<commit_before>"""Functions to simulate scans and maps."""

from __future__ import (absolute_import, division,
                        print_function)

import numpy as np
import numpy.random as ra
import os
from astropy.io import fits
from astropy.table import Table, vstack
from .scan import Scan
from .io import mkdir_p


def simulate_scan(dt=0.04, length=120., speed=4., shape=None, noise_amplitude=1.):
    """Simulate a scan.

    Parameters
    ----------
    dt : float
        The integration time in seconds
    length : float
        Length of the scan in arcminutes
    speed : float
        Speed of the scan in arcminutes / second
    shape : function
        Function that describes the shape of the scan. If None, a
        constant scan is assumed. The zero point of the scan is in the
        *center* of it
    noise_amplitude : float
        Noise level in counts
    """
    if shape is None:
        shape = lambda x : 100
    nbins = np.rint(length / speed / dt)

    times = np.arange(nbins) * dt
    position = np.arange(-nbins / 2, nbins / 2) / nbins * length / 60  # In degrees!

    return times, position, shape(position) + ra.normal(0, noise_amplitude, position.shape)

<commit_msg>Allow a center coordinate different than 0<commit_after>"""Functions to simulate scans and maps."""

from __future__ import (absolute_import, division,
                        print_function)

import numpy as np
import numpy.random as ra
import os
from astropy.io import fits
from astropy.table import Table, vstack
from .scan import Scan
from .io import mkdir_p


def simulate_scan(dt=0.04, length=120., speed=4., shape=None, noise_amplitude=1., center=0.):
    """Simulate a scan.

    Parameters
    ----------
    dt : float
        The integration time in seconds
    length : float
        Length of the scan in arcminutes
    speed : float
        Speed of the scan in arcminutes / second
    shape : function
        Function that describes the shape of the scan. If None, a
        constant scan is assumed. The zero point of the scan is in the
        *center* of it
    noise_amplitude : float
        Noise level in counts
    center : float
        Center coordinate in degrees
    """
    if shape is None:
        shape = lambda x : 100
    nbins = np.rint(length / speed / dt)

    times = np.arange(nbins) * dt
    position = np.arange(-nbins / 2, nbins / 2) / nbins * length / 60 + center# In degrees!

    return times, position, shape(position) + ra.normal(0, noise_amplitude, position.shape)


{'fraction_non_alphanumeric': 0.08277227722772278, 'fraction_numerical': 0.013465346534653465, 'mean_word_length': 2.4508196721311477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1847702', 'n_tokens_mistral': 760, 'n_tokens_neox': 703, 'n_words': 294}