Skip to content

Commit

Permalink
Merge branch '_dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
rabii-chaarani committed Mar 26, 2024
2 parents 6b1c419 + a7f3a93 commit c5ece12
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ jobs:
uses: microsoft/[email protected]
- name: Conda build'
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
shell: bash -l {0}
run: |
conda install -c conda-forge conda-build anaconda-client -y
conda build -c anaconda -c conda-forge -c loop3d --output-folder conda conda
conda install anaconda-client -y
- name: upload windows
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
if: matrix.os == 'windows-latest'
shell: bash -l {0}
run: |
anaconda upload --label main conda/win-64/*.tar.bz2
- name: upload linux
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
if: matrix.os == 'ubuntu-latest'
shell: bash -l {0}
run: |
anaconda upload --label main conda/linux-64/*.tar.bz2
- name: upload macosx
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
if: matrix.os == 'macos-latest'
shell: bash -l {0}
run: |
Expand Down
41 changes: 34 additions & 7 deletions FoldOptLib/examples/misc_functions.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
import numpy as np


def sample_random_dataset(grid, sample_size=2, seed=180):
def sample_random_dataset(bounding_box, sample_size=2, seed=180):
"""
Generate a random dataset of 3D coordinates within a specified model bounding box.
Parameters
----------
bounding_box : ndarray
A 3x3 array where each row represents the minimum and maximum values of x and y coordinates.
sample_size : int, optional
The number of random samples to generate. Default is 2.
seed : int, optional
The seed for the random number generator for reproducibility. Default is 180.
Returns
-------
random_xyz : ndarray
A sample_size x 3 array of random 3D coordinates within the specified bounding box.
"""
# Set the seed for the random number generator for reproducible results
np.random.seed(seed)
# select all xy points with z = 0
xyz = grid[grid[:, 2] == 0]
xmax = xyz[:, 0].max()
ymax = xyz[:, 1].max()

# Extract the maximum x and y coordinates from the bounding box
xmax, ymax = bounding_box[1, 0], bounding_box[1, 1]

# Define the maximum z coordinate (fixed at 0 to only sample model's surface)
zmax = 0.
xn = np.random.uniform(low=0, high=xmax, size=sample_size)
yn = np.random.uniform(low=0, high=ymax, size=sample_size)

# Generate 'sample_size' number of random x-coordinates
xn = np.random.uniform(low=bounding_box[0, 0], high=xmax, size=sample_size)

# Generate 'sample_size' number of random y-coordinates
yn = np.random.uniform(low=bounding_box[0, 1], high=ymax, size=sample_size)

# Create an array of z-coordinates, all set to 'zmax' (fixed z-coordinate for all points)
zn = np.tile(zmax, sample_size)

# Combine the x, y, and z coordinates into a single 2D array (shape: sample_size x 3)
random_xyz = np.array([xn, yn, zn]).T

return random_xyz
2 changes: 1 addition & 1 deletion FoldOptLib/objective_functions/geological_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, constraints: Dict[str, float]):
'fold_axis_wavelength': {'lb':10, 'ub':10, 'mu':10, 'sigma':10, 'w':10},
},
'fold_axial_surface': {
'axial_surface': {'lb':10, 'ub':10, 'mu':10, 'kappa':10, 'w':10}
'axial_surface': {'lb':10, 'ub':10, 'mu':[0.,1.,0.], 'kappa':10, 'w':10}
}
}
lb and ub are the lower and the upper bounds of the constraints and are used only for a restricted
Expand Down
12 changes: 12 additions & 0 deletions FoldOptLib/optimisers/axial_surface_optimiser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import ABC
import gc
from typing import Dict, Any, Optional, Union, Tuple
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -166,6 +167,9 @@ def loglikelihood(self, x, predicted_foliation: np.ndarray,
# Calculate the loglikelihood of the axial surface
loglikelihood = loglikelihood_axial_surface(angle_difference) + geological_knowledge(x)

del angle_difference
gc.collect()

return loglikelihood

def mle_optimisation(self, strike_dip: Tuple[float, float]):
Expand Down Expand Up @@ -193,6 +197,10 @@ def mle_optimisation(self, strike_dip: Tuple[float, float]):

predicted_foliation = self.fold_engine.get_predicted_foliation(axial_normal)
logpdf = self.loglikelihood(axial_normal, predicted_foliation, self.geo_objective)

del predicted_foliation, axial_normal
gc.collect()

return logpdf

def angle_optimisation(self, strike_dip: Tuple[float, float]):
Expand All @@ -219,6 +227,10 @@ def angle_optimisation(self, strike_dip: Tuple[float, float]):
axial_normal /= np.linalg.norm(axial_normal)
predicted_foliation = self.fold_engine.get_predicted_foliation(axial_normal)
angle_difference = is_axial_plane_compatible(predicted_foliation, self.gradient_data)

del predicted_foliation, axial_normal
gc.collect()

return angle_difference

def setup_optimisation(self, geological_knowledge: Optional[Dict[str, Any]] = None):
Expand Down

0 comments on commit c5ece12

Please sign in to comment.