4141
4242logger = logging .getLogger (__name__ )
4343
44+ __all__ = [
45+ "UniverseConstructError" ,
46+ "UniverseConstructor" ,
47+ "get_ApL_data" ,
48+ "get_FF" ,
49+ "get_OP" ,
50+ "get_eqtimes" ,
51+ "get_mean_ApL" ,
52+ "get_thickness" ,
53+ "get_total_area" ,
54+ "mda_gen_selection_mols" ,
55+ "mda_read_trj_tilt_angles" ,
56+ ]
57+
4458
4559def get_thickness (system : System ) -> float :
4660 """
@@ -124,17 +138,17 @@ def get_OP(system: System) -> dict: # noqa: N802 (API name)
124138 return sim_op_data
125139
126140
127- def get_FF (system : System ) -> np .ndarray : # noqa: N802 (API name)
128- """
129- Get numpy table of FormFactor curve.
141+ def _get_2d_array (system : System , fname : str ) -> np .ndarray :
142+ """Get whatever 2D array stored in the DB.
130143
131144 :param system: Simulation object
132- :return: (q,FF,err) numpy table
145+ :param fname: Filename (str)
146+ :return: numpy table
133147 """
134148 fn = os .path .join (
135149 FMDL_SIMU_PATH ,
136150 system ["path" ],
137- "FormFactor.json" ,
151+ fname ,
138152 )
139153 try :
140154 with open (fn ) as json_file :
@@ -148,6 +162,33 @@ def get_FF(system: System) -> np.ndarray: # noqa: N802 (API name)
148162 return np .array (sim_ff_data )
149163
150164
165+ def get_FF (system : System ) -> np .ndarray : # noqa: N802 (API name)
166+ """
167+ Get numpy table of FormFactor curve.
168+
169+ :param system: Simulation object
170+ :return: (q,FF,err) numpy table
171+ """
172+ return _get_2d_array (system , "FormFactor.json" )
173+
174+
175+ def get_density (system : System , domain : str = "total" ) -> np .ndarray :
176+ """Get numpy table of electron density.
177+
178+ :param system: Simulation object
179+ :param domain: total|water|lipids
180+ :return: (z,edens,err) array
181+ """
182+ if domain == "total" :
183+ return _get_2d_array (system , "TotalDensity.json" )
184+ if domain == "lipids" :
185+ return _get_2d_array (system , "LipidDensity.json" )
186+ if domain == "water" :
187+ return _get_2d_array (system , "WaterDensity.json" )
188+ msg = f"get_density supports only total/lipids/water for domain. Got { domain } !"
189+ raise ValueError (msg )
190+
191+
151192def get_quality (
152193 system : System ,
153194 * ,
@@ -228,22 +269,7 @@ def get_ApL_data(system: System, blocksize: float | None = None) -> np.ndarray:
228269
229270 :return: Array (t, value) with blocksize step.
230271 """
231- path = os .path .join (FMDL_SIMU_PATH , system ["path" ], "apl.json" )
232- try :
233- with open (path ) as f :
234- data = json .load (f )
235- except FileNotFoundError as e :
236- msg = "Area per lipid data is absent for system #{}" .format (system ["ID" ])
237- raise FileNotFoundError (msg ) from e
238- except json .JSONDecodeError as e :
239- msg = "Area per lipid data for system #{} in {} is invalid." .format (system ["ID" ], path )
240- raise ValueError (msg ) from e
241- df = np .vstack (
242- [
243- np .array (list (data .keys ()), dtype = float ),
244- np .array (list (data .values ()), dtype = float ),
245- ]
246- ).T
272+ df = _get_2d_array (system , "apl.json" )
247273 if blocksize is not None :
248274 df = block_average_time_series (df , blocksize )
249275 return df
@@ -501,6 +527,3 @@ def _calc_angle(atoms, com) -> float:
501527 total_std_error = np .std (res_aver_angles ) / np .sqrt (n_res )
502528
503529 return angles , res_aver_angles , total_average , total_std_error
504-
505-
506- # -------------------------------------- SEPARATED PART (??) ----------------------
0 commit comments