improve format
This commit is contained in:
+34
-20
@@ -1,37 +1,42 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import glob as glob
|
|
||||||
import copy
|
import copy
|
||||||
|
import glob as glob
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import tables
|
from abc import ABCMeta, abstractmethod
|
||||||
from tables import HDF5ExtError
|
from functools import partial
|
||||||
|
|
||||||
import pymses
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.polynomial.polynomial import polyfit
|
import pymses
|
||||||
from scipy.stats import linregress
|
import tables
|
||||||
|
|
||||||
from pymses.sources.ramses import output
|
|
||||||
from pymses.sources.hop.file_formats import *
|
|
||||||
from pymses.analysis import Camera, raytracing, slicing, splatting
|
|
||||||
from pymses.filters import CellsToPoints
|
|
||||||
from pymses.analysis import ScalarOperator, FractionOperator, MaxLevelOperator
|
|
||||||
from astrophysix.simdm import SimulationStudy
|
from astrophysix.simdm import SimulationStudy
|
||||||
from astrophysix.simdm.experiment import (
|
from astrophysix.simdm.experiment import (
|
||||||
Simulation,
|
|
||||||
AppliedAlgorithm,
|
AppliedAlgorithm,
|
||||||
ParameterSetting,
|
ParameterSetting,
|
||||||
ParameterVisibility,
|
ParameterVisibility,
|
||||||
|
Simulation,
|
||||||
)
|
)
|
||||||
from astrophysix.simdm.results import GenericResult, Snapshot
|
from astrophysix.simdm.results import GenericResult, Snapshot
|
||||||
|
from numpy.polynomial.polynomial import polyfit
|
||||||
|
from pymses.analysis import (
|
||||||
|
Camera,
|
||||||
|
FractionOperator,
|
||||||
|
MaxLevelOperator,
|
||||||
|
ScalarOperator,
|
||||||
|
raytracing,
|
||||||
|
slicing,
|
||||||
|
splatting,
|
||||||
|
)
|
||||||
|
from pymses.filters import CellsToPoints
|
||||||
|
from pymses.sources.hop.file_formats import *
|
||||||
|
from pymses.sources.ramses import output
|
||||||
|
from scipy.stats import linregress
|
||||||
|
from tables import HDF5ExtError
|
||||||
|
|
||||||
from ramses_astrophysix import ramses
|
from ramses_astrophysix import ramses
|
||||||
|
|
||||||
import subprocess
|
|
||||||
from functools import partial
|
|
||||||
from abc import ABCMeta, abstractmethod
|
|
||||||
|
|
||||||
from run_selector import *
|
from run_selector import *
|
||||||
from units import *
|
from units import *
|
||||||
|
|
||||||
@@ -429,6 +434,15 @@ class HDF5Container(BaseProcessor):
|
|||||||
|
|
||||||
name = transform_name + "_" + rule_src_name
|
name = transform_name + "_" + rule_src_name
|
||||||
|
|
||||||
|
self.rules[name] = Rule(
|
||||||
|
self,
|
||||||
|
fn,
|
||||||
|
group=group,
|
||||||
|
unit=unit,
|
||||||
|
description=description,
|
||||||
|
dependencies=[rule_src_name],
|
||||||
|
)
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
self,
|
self,
|
||||||
fn,
|
fn,
|
||||||
|
|||||||
+13
-12
@@ -26,35 +26,36 @@
|
|||||||
# negotiate a specific contract with a legal representative of CEA.
|
# negotiate a specific contract with a legal representative of CEA.
|
||||||
#
|
#
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import os
|
|
||||||
import numpy as N
|
|
||||||
import h5py
|
|
||||||
|
|
||||||
from astrophysix.simdm import SimulationStudy, Project, ProjectCategory
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
|
import h5py
|
||||||
|
import numpy as N
|
||||||
|
from astrophysix import units as U
|
||||||
|
from astrophysix.simdm import Project, ProjectCategory, SimulationStudy
|
||||||
|
from astrophysix.simdm.datafiles import Datafile, PlotInfo, PlotType
|
||||||
from astrophysix.simdm.experiment import (
|
from astrophysix.simdm.experiment import (
|
||||||
Simulation,
|
|
||||||
AppliedAlgorithm,
|
AppliedAlgorithm,
|
||||||
ParameterSetting,
|
ParameterSetting,
|
||||||
ParameterVisibility,
|
ParameterVisibility,
|
||||||
ResolvedPhysicalProcess,
|
ResolvedPhysicalProcess,
|
||||||
|
Simulation,
|
||||||
)
|
)
|
||||||
from astrophysix.simdm.protocol import (
|
from astrophysix.simdm.protocol import (
|
||||||
SimulationCode,
|
|
||||||
AlgoType,
|
|
||||||
Algorithm,
|
Algorithm,
|
||||||
|
AlgoType,
|
||||||
InputParameter,
|
InputParameter,
|
||||||
PhysicalProcess,
|
PhysicalProcess,
|
||||||
Physics,
|
Physics,
|
||||||
|
SimulationCode,
|
||||||
)
|
)
|
||||||
from astrophysix.simdm.results import GenericResult, Snapshot
|
from astrophysix.simdm.results import GenericResult, Snapshot
|
||||||
from astrophysix.simdm.datafiles import Datafile, PlotType, PlotInfo
|
|
||||||
from astrophysix.utils.file import FileType
|
from astrophysix.utils.file import FileType
|
||||||
from astrophysix import units as U
|
from matplotlib import gridspec
|
||||||
|
from mpl_toolkits.axes_grid1 import AxesGrid, Grid
|
||||||
|
|
||||||
from plotter import *
|
from plotter import *
|
||||||
import datetime
|
|
||||||
from mpl_toolkits.axes_grid1 import AxesGrid, Grid
|
|
||||||
from matplotlib import gridspec
|
|
||||||
|
|
||||||
P.rcParams["text.usetex"] = False
|
P.rcParams["text.usetex"] = False
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from matplotlib.widgets import Slider, Button, RadioButtons, LassoSelector
|
|
||||||
from matplotlib.widgets import SpanSelector, PolygonSelector, CheckButtons
|
|
||||||
import matplotlib.patches as patches
|
import matplotlib.patches as patches
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib.lines import Line2D
|
from matplotlib.lines import Line2D
|
||||||
from matplotlib.path import Path
|
from matplotlib.path import Path
|
||||||
|
from matplotlib.widgets import (
|
||||||
|
Button,
|
||||||
|
CheckButtons,
|
||||||
|
LassoSelector,
|
||||||
|
PolygonSelector,
|
||||||
|
RadioButtons,
|
||||||
|
Slider,
|
||||||
|
SpanSelector,
|
||||||
|
)
|
||||||
from scipy.stats import linregress
|
from scipy.stats import linregress
|
||||||
from postprocessor import *
|
|
||||||
from skimage.draw import line
|
from skimage.draw import line
|
||||||
|
|
||||||
|
from postprocessor import *
|
||||||
|
|
||||||
|
|
||||||
class DraggablePoint:
|
class DraggablePoint:
|
||||||
|
|
||||||
|
|||||||
@@ -26,29 +26,30 @@
|
|||||||
# negotiate a specific contract with a legal representative of CEA.
|
# negotiate a specific contract with a legal representative of CEA.
|
||||||
#
|
#
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import os
|
|
||||||
import numpy as N
|
|
||||||
|
|
||||||
from astrophysix.simdm import SimulationStudy, Project, ProjectCategory
|
import os
|
||||||
|
|
||||||
|
import numpy as N
|
||||||
|
from astrophysix import units as U
|
||||||
|
from astrophysix.simdm import Project, ProjectCategory, SimulationStudy
|
||||||
|
from astrophysix.simdm.datafiles import Datafile, PlotInfo, PlotType
|
||||||
from astrophysix.simdm.experiment import (
|
from astrophysix.simdm.experiment import (
|
||||||
Simulation,
|
|
||||||
AppliedAlgorithm,
|
AppliedAlgorithm,
|
||||||
ParameterSetting,
|
ParameterSetting,
|
||||||
ParameterVisibility,
|
ParameterVisibility,
|
||||||
ResolvedPhysicalProcess,
|
ResolvedPhysicalProcess,
|
||||||
|
Simulation,
|
||||||
)
|
)
|
||||||
from astrophysix.simdm.protocol import (
|
from astrophysix.simdm.protocol import (
|
||||||
SimulationCode,
|
|
||||||
AlgoType,
|
|
||||||
Algorithm,
|
Algorithm,
|
||||||
|
AlgoType,
|
||||||
InputParameter,
|
InputParameter,
|
||||||
PhysicalProcess,
|
PhysicalProcess,
|
||||||
Physics,
|
Physics,
|
||||||
|
SimulationCode,
|
||||||
)
|
)
|
||||||
from astrophysix.simdm.results import GenericResult, Snapshot
|
from astrophysix.simdm.results import GenericResult, Snapshot
|
||||||
from astrophysix.simdm.datafiles import Datafile, PlotType, PlotInfo
|
|
||||||
from astrophysix.utils.file import FileType
|
from astrophysix.utils.file import FileType
|
||||||
from astrophysix import units as U
|
|
||||||
|
|
||||||
# ----------------------------------------------- Project creation --------------------------------------------------- #
|
# ----------------------------------------------- Project creation --------------------------------------------------- #
|
||||||
# Available project categories are :
|
# Available project categories are :
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import multiprocessing
|
|||||||
# multiprocessing module.
|
# multiprocessing module.
|
||||||
import multiprocessing.pool
|
import multiprocessing.pool
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -1,16 +1,17 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os
|
|
||||||
import glob
|
|
||||||
from shutil import copy
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import numpy as np
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
from shutil import copy
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from pp_params import *
|
|
||||||
from plotter import *
|
from plotter import *
|
||||||
from postprocessor import *
|
from postprocessor import *
|
||||||
|
from pp_params import *
|
||||||
|
|
||||||
fake_pp = PostProcessor()
|
fake_pp = PostProcessor()
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -8,27 +8,30 @@ This is the plotter module.
|
|||||||
@author Noé Brucy 2019-2020
|
@author Noé Brucy 2019-2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import tables
|
|
||||||
import numpy as np
|
|
||||||
from scipy.stats import linregress
|
|
||||||
from numpy.polynomial.polynomial import polyfit
|
|
||||||
from scipy.ndimage.filters import gaussian_filter1d
|
|
||||||
from scipy import optimize
|
|
||||||
from astrophysix.simdm.datafiles import Datafile, PlotType, PlotInfo
|
|
||||||
from astrophysix.utils.file import FileType
|
|
||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
|
import numpy as np
|
||||||
|
import tables
|
||||||
|
from astrophysix.simdm.datafiles import Datafile, PlotInfo, PlotType
|
||||||
|
from astrophysix.utils.file import FileType
|
||||||
|
from numpy.polynomial.polynomial import polyfit
|
||||||
|
from scipy import optimize
|
||||||
|
from scipy.ndimage.filters import gaussian_filter1d
|
||||||
|
from scipy.stats import linregress
|
||||||
|
|
||||||
if os.environ.get("DISPLAY", "") == "":
|
if os.environ.get("DISPLAY", "") == "":
|
||||||
print("No display found. Using non-interactive Agg backend")
|
print("No display found. Using non-interactive Agg backend")
|
||||||
mpl.use("Agg")
|
mpl.use("Agg")
|
||||||
import pylab as P
|
|
||||||
from comparator import *
|
|
||||||
import pspec_read
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import pylab as P
|
||||||
|
|
||||||
|
import pspec_read
|
||||||
|
from comparator import *
|
||||||
|
|
||||||
filetype_from_ext = {ext: ft for ft in FileType for ext in ft.extension_list}
|
filetype_from_ext = {ext: ft for ft in FileType for ext in ft.extension_list}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+17
-14
@@ -1,13 +1,15 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
import astropy.units as u
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import pymses.utils.regions as reg
|
||||||
|
from fil_finder import FilFinder2D
|
||||||
|
from pymses.filters import RegionFilter
|
||||||
|
from skimage.morphology import medial_axis
|
||||||
|
|
||||||
import pspec_new
|
import pspec_new
|
||||||
from baseprocessor import *
|
from baseprocessor import *
|
||||||
import pymses.utils.regions as reg
|
|
||||||
from pymses.filters import RegionFilter
|
|
||||||
import astropy.units as u
|
|
||||||
from fil_finder import FilFinder2D
|
|
||||||
import pickle
|
|
||||||
from skimage.morphology import medial_axis
|
|
||||||
|
|
||||||
# Getters
|
# Getters
|
||||||
|
|
||||||
@@ -82,6 +84,15 @@ def mean_by_bins(
|
|||||||
# For each cell, bin_number contains the number of the bins it belongs to
|
# For each cell, bin_number contains the number of the bins it belongs to
|
||||||
bin_number = np.zeros(len(y))
|
bin_number = np.zeros(len(y))
|
||||||
|
|
||||||
|
# Go through the min value of x of each bin
|
||||||
|
for x_min in x_bins[1:-1]:
|
||||||
|
bin_number = bin_number + (x > x_min).astype(int)
|
||||||
|
|
||||||
|
# Compute the mean in each bin
|
||||||
|
y_mean = np.zeros(len(x_bins) - 1)
|
||||||
|
for i in range(len(y_mean)):
|
||||||
|
y_mean[i] = np.mean(y[bin_number == i])
|
||||||
|
|
||||||
# Get the center of each bin
|
# Get the center of each bin
|
||||||
if logbins:
|
if logbins:
|
||||||
centers = 10 ** (0.5 * (np.log10(x_bins[1:]) + np.log10(x_bins[:-1])))
|
centers = 10 ** (0.5 * (np.log10(x_bins[1:]) + np.log10(x_bins[:-1])))
|
||||||
@@ -1044,14 +1055,6 @@ class PostProcessor(HDF5Container):
|
|||||||
alpha_g = (2.0 / 3) * alpha_g
|
alpha_g = (2.0 / 3) * alpha_g
|
||||||
return alpha_g
|
return alpha_g
|
||||||
|
|
||||||
alpha_g = self._ax_avg(getter_alpha_grav, "z", unit=cst.none, surf_qty=True) / (
|
|
||||||
coldens * T_avg
|
|
||||||
)
|
|
||||||
|
|
||||||
# alpha
|
|
||||||
alpha_g = (2.0 / 3) * alpha_g
|
|
||||||
return alpha_g
|
|
||||||
|
|
||||||
def _sinks(self):
|
def _sinks(self):
|
||||||
csv_name = (
|
csv_name = (
|
||||||
self.path
|
self.path
|
||||||
|
|||||||
+5
-4
@@ -1,10 +1,11 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import re
|
|
||||||
import munch
|
|
||||||
import yaml
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
import munch
|
||||||
|
import numpy as np
|
||||||
|
import yaml
|
||||||
|
|
||||||
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
|||||||
+6
-42
@@ -1,25 +1,19 @@
|
|||||||
"""Compute power spectra"""
|
"""Compute power spectra"""
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division, print_function
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from builtins import range
|
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from builtins import range
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.fft import fftn, ifft
|
|
||||||
|
|
||||||
import pymses
|
import pymses
|
||||||
from pymses.analysis import ScalarOperator, Camera
|
|
||||||
from pymses.analysis import cube3d
|
|
||||||
import pymses.utils.misc
|
import pymses.utils.misc
|
||||||
|
|
||||||
import tables as T
|
import tables as T
|
||||||
|
from i_utils import args, tools
|
||||||
from i_utils import args
|
from numpy.fft import fftn, ifft
|
||||||
from i_utils import tools
|
from pymses.analysis import Camera, ScalarOperator, cube3d
|
||||||
|
|
||||||
__generator__ = "pspec_new.py"
|
__generator__ = "pspec_new.py"
|
||||||
__version__ = "0.2"
|
__version__ = "0.2"
|
||||||
@@ -434,37 +428,6 @@ parser = argparse.ArgumentParser(
|
|||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument("repo", help="RAMSES output repository", type=str, default=".")
|
|
||||||
parser.add_argument("iouts", help="output numbers", type=args.selection, default=":")
|
|
||||||
parser.add_argument(
|
|
||||||
"outfile", help="output file format (see below for fields)", type=str
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-n",
|
|
||||||
"--nodename",
|
|
||||||
help="node name format (see below for fields)",
|
|
||||||
type=str,
|
|
||||||
default="/out_%(iout)05d/d%(dim)d/%(varname)s",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-O",
|
|
||||||
"--order",
|
|
||||||
help="byte order (= for native)",
|
|
||||||
type=str,
|
|
||||||
default="=",
|
|
||||||
choices=["<", ">", "="],
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-c",
|
|
||||||
"--center",
|
|
||||||
help="coordinates of the center",
|
|
||||||
type=args.center,
|
|
||||||
default=[0.5, 0.5, 0.5],
|
|
||||||
)
|
|
||||||
parser.add_argument("-s", "--size", help="cube size", type=float, default=1.0)
|
|
||||||
parser.add_argument(
|
|
||||||
"-l", "--level", help="cube level (default: levelMIN)", type=int, default=0
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"repo", help="RAMSES output repository", type=str, default=".", nargs="?"
|
"repo", help="RAMSES output repository", type=str, default=".", nargs="?"
|
||||||
)
|
)
|
||||||
@@ -617,6 +580,7 @@ def main(arg):
|
|||||||
% (clvl, read_lvl)
|
% (clvl, read_lvl)
|
||||||
)
|
)
|
||||||
clvl = read_lvl
|
clvl = read_lvl
|
||||||
|
|
||||||
# Degrade cubes ----------------------------------------------------------------
|
# Degrade cubes ----------------------------------------------------------------
|
||||||
if clvl < read_lvl:
|
if clvl < read_lvl:
|
||||||
print("Degrade cubes")
|
print("Degrade cubes")
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
from builtins import str
|
from builtins import str
|
||||||
import tables as T
|
|
||||||
import numpy as np
|
|
||||||
import matplotlib.pyplot as P
|
|
||||||
|
|
||||||
|
import matplotlib.pyplot as P
|
||||||
|
import numpy as np
|
||||||
|
import tables as T
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# 3D
|
# 3D
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
|
|
||||||
from astrophysix.simdm.protocol import (
|
from astrophysix.simdm.protocol import (
|
||||||
SimulationCode,
|
|
||||||
AlgoType,
|
|
||||||
Algorithm,
|
Algorithm,
|
||||||
|
AlgoType,
|
||||||
InputParameter,
|
InputParameter,
|
||||||
PhysicalProcess,
|
PhysicalProcess,
|
||||||
Physics,
|
Physics,
|
||||||
|
SimulationCode,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Simulation code definition #
|
# Simulation code definition #
|
||||||
ramses = SimulationCode(
|
ramses = SimulationCode(
|
||||||
name="Ramses 3 (MHD)",
|
name="Ramses 3 (MHD)",
|
||||||
|
|||||||
+11
-3
@@ -2,12 +2,14 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import glob
|
import glob
|
||||||
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pp_params import *
|
|
||||||
import f90nml
|
import f90nml
|
||||||
|
|
||||||
|
from pp_params import *
|
||||||
|
|
||||||
|
|
||||||
class NamelistRecursive:
|
class NamelistRecursive:
|
||||||
def __init__(self, namelist):
|
def __init__(self, namelist):
|
||||||
@@ -107,7 +109,13 @@ class RunSelector:
|
|||||||
in_nums[run] = nums_temp
|
in_nums[run] = nums_temp
|
||||||
|
|
||||||
for i, run in enumerate(self.runs):
|
for i, run in enumerate(self.runs):
|
||||||
self.nums[run] = self.get_nums(run, in_nums[run], time_min, time_max, time)
|
self.nums[run] = self.get_nums(
|
||||||
|
run,
|
||||||
|
in_nums[run],
|
||||||
|
time_min,
|
||||||
|
time_max,
|
||||||
|
time,
|
||||||
|
)
|
||||||
|
|
||||||
def select(
|
def select(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user