Skip to content

Commit

Permalink
remove __pycache__ + test code
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias77515 committed Sep 10, 2024
1 parent 543a0ba commit 1aa8ab8
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
from pyoperators import *
from FMM.pipeline import PipelineEnd2End
from CMM.pipeline import Pipeline


simu = 'CMM'

if __name__ == "__main__":

### Common MPI arguments
comm = MPI.COMM_WORLD


if simu == 'FMM':

try:
file = str(sys.argv[1])
except IndexError:
file = None

### Initialization
pipeline = PipelineEnd2End(comm)

### Execution
pipeline.main(specific_file=file)

elif simu == 'CMM':

seed_noise = int(sys.argv[1])

### Initialization
pipeline = Pipeline(comm, 1, seed_noise)

### Execution
pipeline.main()


16 changes: 16 additions & 0 deletions src/running_scrips/run_cmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys

from pyoperators import *

from CMM.pipeline import Pipeline

seed_noise = int(sys.argv[1])

### MPI common arguments
comm = MPI.COMM_WORLD

if __name__ == "__main__":

pipeline = Pipeline(comm, 1, seed_noise)

pipeline.main()
20 changes: 20 additions & 0 deletions src/running_scrips/run_cmm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

#SBATCH --job-name=FMM

# we ask for n MPI tasks with N cores each on c nodes

#SBATCH --partition=htc
#SBATCH --nodes=1 # c
#SBATCH --ntasks-per-node=1 # n
#SBATCH --cpus-per-task=4 # N
#SBATCH --mem=60G
#SBATCH --time=3-00:00:00
#SBATCH --output=mulitple_jobs_%j.log
#SBATCH --array=1-500

export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}

module load mpich

mpirun -np $SLURM_NTASKS python run_cmm.py $1
45 changes: 45 additions & 0 deletions src/running_scrips/run_fit_fmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os

import matplotlib.pyplot as plt
import numpy as np
from multiprocess import Pool
from pyoperators import MPI
from schwimmbad import MPIPool

from lib.Qfit import FitEllSpace
from lib.Qfoldertools import MergeAllFiles
from lib.Qspectra_component import SkySpectra

comm = MPI.COMM_WORLD

### Concatenate all realizations
files = MergeAllFiles(
"/Users/mregnier/Desktop/git/Pipeline/src/FMM/CMBDUST_nrec2_new_code/spectrum/"
)

nus_index = np.array([True, True, False, False, False, False, False, False, True])
NBINS = 16

ell = files._reads_one_file(0, "ell")[:NBINS]
nus = files._reads_one_file(0, "nus")[nus_index]

BBsignal = np.mean(files._reads_all_files("Dls"), axis=0)[:, nus_index, :NBINS][
nus_index, :, :NBINS
]
BBnoise = files._reads_all_files("Nl")[:, :, nus_index, :NBINS][:, nus_index, :, :NBINS]
BBsignal -= np.mean(BBnoise, axis=0)

sky = SkySpectra(ell, nus)
fit = FitEllSpace(ell, BBsignal, BBnoise, model=sky.model)

samples, samples_flat = fit.run(300, 10, discard=200, comm=comm)

plt.figure()
plt.plot(samples[..., 0], "-k", alpha=0.1)
plt.axhline(0)
plt.show()

print()
print(f"Average : {np.mean(samples_flat, axis=0)}")
print(f"Error : {np.std(samples_flat, axis=0)}")
print()
23 changes: 23 additions & 0 deletions src/running_scrips/run_fmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
from pyoperators import *

from ..FMM.pipeline import PipelineEnd2End
#from .FMM.pipeline import PipelineEnd2End


stop
try:
file = str(sys.argv[1])
except IndexError:
file = None

if __name__ == "__main__":

### Common MPI arguments
comm = MPI.COMM_WORLD

### Initialization
pipeline = PipelineEnd2End(comm)

### Execution
pipeline.main(specific_file=file)
20 changes: 20 additions & 0 deletions src/running_scrips/run_fmm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

#SBATCH --job-name=FMM

# we ask for n MPI tasks with N cores each on c nodes

#SBATCH --partition=htc
#SBATCH --nodes=1 # c
#SBATCH --ntasks-per-node=1 # n
#SBATCH --cpus-per-task=4 # N
#SBATCH --mem=60G
#SBATCH --time=3-00:00:00
#SBATCH --output=mulitple_jobs_%j.log
#SBATCH --array=1-500

export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}

module load mpich

mpirun -np $SLURM_NTASKS python src/run_fmm.py
1 change: 1 addition & 0 deletions src/running_scrips/run_spectra_cmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from CMM.spectrum.get_spectra import Spectra

0 comments on commit 1aa8ab8

Please sign in to comment.