Пример #1
0
static int
PyCosmoObject_init(struct PyCosmoObject* self, PyObject *args, PyObject *kwds)
{
    double DH;
    int flat;
    double omega_m, omega_l, omega_k;

    free(self->cosmo);

    if (!PyArg_ParseTuple(args, 
                          (char*)"diddd", 
                          &DH, &flat, &omega_m, &omega_l, &omega_k)) {
        printf("failed to Parse init");
        return -1;
    }

    self->cosmo = cosmo_new(DH, flat, omega_m, omega_l, omega_k);
    if (self->cosmo == NULL) {
        PyErr_SetString(PyExc_MemoryError, "Failed to allocate struct cosmo");
        return -1;
    }
    return 0;
}
Пример #2
0
struct shear* shear_init(const char* config_file) {

    struct shear* shear = calloc(1, sizeof(struct shear));
    if (shear == NULL) {
        printf("Failed to alloc shear struct\n");
        exit(EXIT_FAILURE);
    }

    shear->config=config_read(config_file);

    struct config* config=shear->config;
    printf("config structure:\n");
    config_print(config);

    // the temporary output file where we write everything locally, then copy
    // to the nfs file system after
    shear_open_output(shear);

    // now initialize the structures we need
    printf("Initalizing cosmo in flat universe\n");
    int flat=1;
    double omega_k=0;
    shear->cosmo = cosmo_new(config->H0, flat, 
                             config->omega_m, 
                             1-config->omega_m, 
                             omega_k);

    printf("cosmo structure:\n");
    cosmo_print(shear->cosmo);

    printf("Initalizing healpix at nside: %ld\n", config->nside);
    shear->hpix = hpix_new(config->nside);


    // this is a growable stack for holding pixels
    printf("Creating pixel stack\n");
    shear->pixstack = i64stack_new(0);
    //shear->pixstack->realloc_multval = 1.1;

    // finally read the data
    shear->lcat = lcat_read(config->lens_file);



    printf("Adding Dc to lenses\n");
    lcat_add_da(shear->lcat, shear->cosmo);
    //lcat_print_firstlast(shear->lcat);
    lcat_print_one(shear->lcat, shear->lcat->size-1);


    shear->scat = scat_read(config->source_file);

    printf("Adding hpixid to sources\n");
    scat_add_hpixid(shear->scat, shear->hpix);
    printf("Adding revind to scat\n");
    scat_add_rev(shear->scat, shear->hpix);


#ifdef WITH_TRUEZ
    scat_add_dc(shear->scat, shear->cosmo);
#endif

    //scat_print_firstlast(shear->scat);
    scat_print_one(shear->scat, shear->scat->size-1);

    //sleep(1000);


#ifdef NO_INCREMENTAL_WRITE
    // this holds the sums for each lens
    shear->lensums = lensums_new(shear->lcat->size, config->nbin);
    for (size_t i=0; i<shear->lensums->size; i++) {
        shear->lensums->data[i].zindex = shear->lcat->data[i].zindex;
    }
#else
    shear->lensum = lensum_new(config->nbin);
    shear->lensum_tot = lensum_new(config->nbin);
#endif

    return shear;

}