smashbox.test_mesh_from_graffas

Created on Thu Oct 9 10:48:18 2025

@author: maxime

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3"""
 4Created on Thu Oct  9 10:48:18 2025
 5
 6@author: maxime
 7"""
 8
 9if __name__ == "__main__":
10
11    import smashbox
12    import numpy as np
13
14    # St Lo
15    info_simu_smash = {
16        # "domain": {"left": 807000, "right": 837000, "bottom": 6460000, "top": 6510000},
17        # "domain": {"left": 377000, "right": 450000, "bottom": 6840000, "top": 6920000},
18        "domain": {
19            "left": 925000.0,
20            "bottom": 6230000.0,
21            "right": 974000.0,
22            "top": 6255000.0,
23        },
24        "nom_long": "vivarais",
25        "resolution_sim": 1000.0,
26    }
27    bbox = smashbox.tools.tools.infograffas_bbox_extractor(info_simu_smash)
28
29    sb = smashbox.SmashBox()
30
31    sb.myparam.set_param("bbox", bbox)
32
33    sb.newmodel("graffas_zone")
34
35    sb.graffas_zone.mysetup.update_setup(
36        {
37            "pet_directory": "/home/maxime/DATA/ETP-SFR-FRA-INTERA_L93",
38            "prcp_directory": "/home/maxime/DATA/PLUIE",
39            "qobs_directory": "/home/maxime/DATA/QOBS_SITE_60M",
40        }
41    )  # Change value of the Smash setup
42
43    sb.graffas_zone.generate_mesh(
44        query="(SURF>40) & (INFLUENCE=='Influence nulle ou faible')"
45    )  # direct method to build the mesh (recommended)
46
47    sb.graffas_zone.myplot.plot_mesh()
48
49    sb.graffas_zone.mymesh.mesh["nrow"]
50    sb.graffas_zone.mymesh.mesh["ncol"]
51
52    nrow = 51
53    ncol = 31
54    chunk_size = 18
55    nb_chunk = 21
56    graffas_prcp = np.zeros(shape=(nrow, ncol, nb_chunk * chunk_size))
57    fctr = 100
58    for i in range(nb_chunk):
59        graffas_prcp[:, :, i * chunk_size : (i + 1) * chunk_size] = (
60            fctr
61            * np.arange(i * chunk_size, (i + 1) * chunk_size)
62            / (chunk_size * nb_chunk)
63            * np.cos(np.arange(0, chunk_size * 10, 10) * np.pi / 180)
64        )
65    graffas_prcp = np.where(graffas_prcp < 0, 0.0, graffas_prcp)
66
67    sb.graffas_zone.atmos_data_connector(input_prcp=graffas_prcp, input_dt=3600.0)
68
69    sb.graffas_zone.model()