Skip to content

2 d complete#1

Open
jbrezmorf wants to merge 4 commits intomainfrom
2D_complete
Open

2 d complete#1
jbrezmorf wants to merge 4 commits intomainfrom
2D_complete

Conversation

@jbrezmorf
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor Author

@jbrezmorf jbrezmorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old ... nekomentuju
Pro strukturu repozitáře se můžete inspirovat např. zde:
MLMC

Comment thread grf.py
# EMPIRICKÝ VARIOGRAM gamma(h) = 0.5 * E[(f(x)-f(x+h))^2]
# =============================================================================

def empirical_variogram(x, field, n_bins=30, n_sample=300):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Přesuňte do samostatného souboru diagnostic.py.
V tomto modulu by zůstalo pouze generování.

Comment thread main_fields.py
# BOD 3: GRF 1D
# =============================================================================

x_reg = np.linspace(0, L, N)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zkuste refaktorovat do podoby numerického a grafického testu.
pole generované pomocí NFFT by se porovnalo s polem generovaným FFT
testovala by se L2 norma np.linalg.norm(nfft_grf - interpolate(fft_grf, ..)) +
grafy.

Soubory přejmenujte na test_... a přesuňte do podadresáře 'tests'.
Následně se testy spustí pomocí nástroje 'pytest'

Comment thread grf.py Outdated
C(r) = sigma^2 * exp(-|r|^2 / 2*phi^2)
S(w) = sigma^2 * (sqrt(2pi)*phi)^dim * exp(-|w|^2*phi^2/2)
"""
def __init__(self, L, N_freq, phi, sigma=1.0, dim=1):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @DataClass or @attrs.class to simplify the constructor.
Use type anotations for function parameters and return type.
Document string for functions/metods (here spectral density)

In particular:

  • Does self.L mean correlation length?
  • Meaning of self.phi?
  • Is omega_mag array of points in Fourier space, what shape it has?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 4766aae - both classes use @DataClass, f_points computed in post_init via field(init=False). Type annotations and NumPy-style docstrings added throughout.

Comment thread grf.py
# =============================================================================

def make_hermitian_nd(f_hat):
"""nD hermitovská symetrie v centrovaném pořadí (DC uprostřed na indexu N//2)."""
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better doc string, shape and format of the input; shape of the output.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 4766aae – docstring now documents input shape (N,)^dim, DC index convention, and output guarantee (real-valued IFFT).

- @DataClass on both correlation classes, f_points via field(init=False)
- type annotations on all functions (np.ndarray, int | None, bool)
- NumPy-style docstrings with Parameters / Returns / Raises
- empirical_variogram: vectorized triu_indices, works for 1D and 2D
- removed unused scipy.fft imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants