@@ -62,6 +62,95 @@ def __repr__(self) -> str:
6262 f"units={ self ._units } )"
6363 )
6464
65+ def _repr_html_ (self ) -> str :
66+ """Return an HTML representation of the template for Jupyter notebooks."""
67+ # Format dimensions
68+ dim_rows = ""
69+ if self ._dim_names :
70+ for i , name in enumerate (self ._dim_names ):
71+ size = self ._dim_sizes [i ] if i < len (self ._dim_sizes ) else "Not set"
72+ is_spatial = "✓" if name in self ._spatial_dim_names else ""
73+ dim_rows += f"<tr><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ name } </td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ size } </td><td style='padding: 8px; text-align: center; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ is_spatial } </td></tr>"
74+
75+ # Format coordinates
76+ coord_rows = ""
77+ all_coords = list (self ._physical_coord_names ) + list (self ._logical_coord_names )
78+ for coord in all_coords :
79+ coord_type = "Physical" if coord in self ._physical_coord_names else "Logical"
80+ unit = self ._units .get (coord , None )
81+ unit_str = f"{ unit .name } " if unit else "—"
82+ coord_rows += f"<tr><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ coord } </td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ coord_type } </td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ unit_str } </td></tr>"
83+
84+ # Format units
85+ unit_rows = ""
86+ for key , unit in self ._units .items ():
87+ unit_rows += f"<tr><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ key } </td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{ unit .name } </td></tr>"
88+
89+ html = f"""
90+ <div style="font-family: monospace; border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 5px; padding: 15px; max-width: 1000px;">
91+ <div style="padding: 10px; margin: -15px -15px 15px -15px; border-bottom: 2px solid rgba(128, 128, 128, 0.3);">
92+ <strong style="font-size: 1.1em;">{ self .__class__ .__name__ } </strong>
93+ </div>
94+ <div style="margin-bottom: 15px;">
95+ <strong>Template Name:</strong> { self .name } <br>
96+ <strong>Data Domain:</strong> { self ._data_domain } <br>
97+ <strong>Default Variable:</strong> { self ._default_variable_name } <br>
98+ <strong>Chunk Shape:</strong> { self ._var_chunk_shape if self ._var_chunk_shape else 'Not set' }
99+ </div>
100+ <details open>
101+ <summary style="cursor: pointer; font-weight: bold; margin-bottom: 8px;">▸ Dimensions ({ len (self ._dim_names )} )</summary>
102+ <div style="margin-left: 20px;">
103+ <table style="width: 100%; border-collapse: collapse;">
104+ <thead>
105+ <tr style="border-bottom: 2px solid rgba(128, 128, 128, 0.4);">
106+ <th style="text-align: left; padding: 8px; font-weight: 600;">Name</th>
107+ <th style="text-align: left; padding: 8px; font-weight: 600;">Size</th>
108+ <th style="text-align: center; padding: 8px; font-weight: 600;">Spatial</th>
109+ </tr>
110+ </thead>
111+ <tbody>
112+ { dim_rows if dim_rows else '<tr><td colspan="3" style="padding: 8px; opacity: 0.5; text-align: left;">No dimensions defined</td></tr>' }
113+ </tbody>
114+ </table>
115+ </div>
116+ </details>
117+ <details open>
118+ <summary style="cursor: pointer; font-weight: bold; margin: 15px 0 8px 0;">▸ Coordinates ({ len (all_coords )} )</summary>
119+ <div style="margin-left: 20px;">
120+ <table style="width: 100%; border-collapse: collapse;">
121+ <thead>
122+ <tr style="border-bottom: 2px solid rgba(128, 128, 128, 0.4);">
123+ <th style="text-align: left; padding: 8px; font-weight: 600;">Name</th>
124+ <th style="text-align: left; padding: 8px; font-weight: 600;">Type</th>
125+ <th style="text-align: left; padding: 8px; font-weight: 600;">Units</th>
126+ </tr>
127+ </thead>
128+ <tbody>
129+ { coord_rows if coord_rows else '<tr><td colspan="3" style="padding: 8px; opacity: 0.5; text-align: left;">No coordinates defined</td></tr>' }
130+ </tbody>
131+ </table>
132+ </div>
133+ </details>
134+ <details>
135+ <summary style="cursor: pointer; font-weight: bold; margin: 15px 0 8px 0;">▸ Units ({ len (self ._units )} )</summary>
136+ <div style="margin-left: 20px;">
137+ <table style="width: 100%; border-collapse: collapse;">
138+ <thead>
139+ <tr style="border-bottom: 2px solid rgba(128, 128, 128, 0.4);">
140+ <th style="text-align: left; padding: 8px; font-weight: 600;">Key</th>
141+ <th style="text-align: left; padding: 8px; font-weight: 600;">Unit</th>
142+ </tr>
143+ </thead>
144+ <tbody>
145+ { unit_rows if unit_rows else '<tr><td colspan="2" style="padding: 8px; opacity: 0.5; text-align: left;">No units defined</td></tr>' }
146+ </tbody>
147+ </table>
148+ </div>
149+ </details>
150+ </div>
151+ """
152+ return html
153+
65154 def build_dataset (
66155 self ,
67156 name : str ,
0 commit comments