-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathideal_csv_structure.html
More file actions
435 lines (404 loc) · 16.9 KB
/
ideal_csv_structure.html
File metadata and controls
435 lines (404 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!DOCTYPE html>
<html>
<head>
<title>Recommended CSV format for ecosystem (hydro/geo/bio/climatic) time-series data</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.header {
display: flex;
justify-content: space-between;
align-items: center;
}
.header h1 {
margin-right: 10px;
}
body {
font-family: Arial, sans-serif;
}
.table {
background-color: #f8f9fa;
transition: all 0.3s;
}
.table th {
background-color: #007bff;
color: white;
cursor: pointer;
transition: background-color 0.3s;
}
.table th:hover {
background-color: #0056b3;
}
.table td {
transition: all 0.3s;
}
th, td {
text-align: center;
vertical-align: top !important;
}
.optional-column {
background-color: #a9a9a9 !important;
color: #333;
}
.optional-column:hover {
background-color: #d3d3d3 !important;
}
.color-key {
text-align: right;
margin-bottom: 10px;
}
.key-item {
display: inline-block;
margin-left: 10px;
padding: 5px;
}
.key-item span {
display: inline-block;
width: 20px;
height: 20px;
margin-right: 5px;
vertical-align: middle;
}
.shadowtext {
color: #333333;
}
.lite {
color: #999999;
}
.tooltip {
padding: 5px 10px;
background-color: black;
color: white;
border-radius: 5px;
z-index: 1000; /* High z-index to ensure visibility */
}
.subparen {
font-size: 0.7em;
color: black;
}
.spec-cell {
background-color: #000c1a !important;
}
.td-titled {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container mt-5">
<!--<div class="header">-->
<div>
<h1><a href="https://macrosheds.org">MacroSheds</a> quick guide</h1>
<h3>Publishing clean and reusable environmental data</h3>
</div>
<!--</div>-->
<hr>
<br>
<p>Hover the cells below for more detail.</p>
<p>For a complete guide to file preparation, visit <a href="https://edirepository.org/resources/cleaning-data-and-quality-control">EDI</a>.
<br><br>
<h4>File formatting</h4>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tab1">Wide format (preferred)</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab2">Long format</a>
</li>
</ul>
<!-- TAB ONE -->
<div class="tab-content">
<div id="tab1" class="container tab-pane active">
<br>
<br>
<h4>Generic example</h4>
<div class="color-key">
<div class="key-item">
<span style="background-color: #007bff"></span> Required
</div>
<div class="key-item">
<span style="background-color: #a9a9a9"></span> Optional
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-generic">
<thead>
<tr>
<th data-title="Ideally use UTC (coordinated universal time) for datetimes; In any case, make sure you specify time zone in metadata. If you're using local time, also mention whether DST is being observed.">date/<br>datetime</th>
<th data-title="Site IDs in your own custom format. Include site details in metadata (coordinates, CRS, elevation, description).">site_code</th>
<th class="optional-column" data-title="e.g. different depths in a large river">group/<br>treatment</th>
<th data-title="Units can be included in the parameter name or in metadata. Define methods in metadata.">parameter1<br><span class="subparen">(consider <a href="https://csdms.colorado.edu/wiki/CSN_Searchable_List-Names" style="color: darkblue">CSDMS standard names</a>)</span></th>
<th data-title="Numeric QC flag codes with definitions in metadata. You could have just one flag column if it applies across all your data columns.">parameter1_flag</th>
<th class="optional-column" data-title="Units can be included in the parameter name or in metadata. Define methods in metadata.">parameter2</th>
<th class="optional-column" data-title="Numeric QC flag codes with definitions in metadata. You could also have just one flag column if it applies across all your data columns.">parameter2_flag</th>
<th class="optional-column" data-title="Additional parameters">...</th>
<th class="optional-column" data-title="Avoid if possible! All quality information should be encoded as flags. Notes can still be used to designate interesting observations.">notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>YYYY-MM-DD<br><span style="color: #a9a9a9">hh:mm:ss</span></td>
<td>character</td>
<td style="color: #a9a9a9">character</td>
<td>numeric</td>
<td>integer</td>
<td style="color: #a9a9a9">numeric</td>
<td style="color: #a9a9a9">integer</td>
<td style="color: #a9a9a9">...</td>
<td style="color: #a9a9a9">character</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<h4>Specific example</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th class="spec-cell" data-title="Timezone defined in metadata: UTC">datetime</th>
<th class="spec-cell" data-title="Coordinates, CRS, elevation, description defined in metadata">site_code</th>
<th class="spec-cell" data-title="Specific conductance. Units: uS/cm. Method: resistance (Vernier probe model). All defined in metadata.">spec_cond</th>
<th class="spec-cell" data-title='Code 310 defined in metadata: "below detection limit; estimated as 1/2 detection limit"'>spec_cond_flag</th>
<th class="spec-cell" data-title="Molecular nitrate. Units: mg/L. Method: absorbance (YSI probe model). All defined in metadata.">nitrate</th>
<th class="spec-cell" data-title='Code 311 defined in metadata: "sensor out of water"'>nitrate_flag</th>
</tr>
</thead>
<tbody>
<tr>
<td>2016-01-01 00:00:00</td>
<td>salinas1</td>
<td>9.40</td>
<td></td>
<td>1.81</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:15:00</td>
<td>salinas1</td>
<td>9.43</td>
<td></td>
<td class="td-titled" data-title='Use NA to designate missing values'>NA</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:30:00</td>
<td>salinas1</td>
<td>0.01</td>
<td class="td-titled" data-title='Code 310 defined in metadata: "below detection limit; estimated as 1/2 detection limit"'>310</td>
<td>1.82</td>
<td></td>
</tr>
<tr>
<td colspan="6" style="text-align: center; border: none;">...</td>
</tr>
<tr>
<td>2023-12-31 23:45:00</td>
<td class="td-titled" data-title='You can include multiple sites in a file, or separate them. Same goes for parameters and time spans'>nacimiento3</td>
<td>7.44</td>
<td></td>
<td>0.05</td>
<td class="td-titled" data-title='Code 311 defined in metadata: "sensor out of water"'>311</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
<!-- TAB TWO -->
<div id="tab2" class="container tab-pane fade">
<br>
<br>
<h4>generic example</h4>
<div class="color-key">
<div class="key-item">
<span style="background-color: #007bff"></span> Required
</div>
<div class="key-item">
<span style="background-color: #a9a9a9"></span> Optional
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-generic">
<thead>
<tr>
<th data-title="Ideally use UTC (coordinated universal time) for datetimes; in any case, make sure you specify time zone somewhere.">date/<br>datetime</th>
<th data-title="Site IDs in your own custom format. Include site details in metadata (coordinates, CRS, elevation, description).">site_code</th>
<th class="optional-column" data-title="e.g. different depths in a large river">group/<br>treatment</th>
<th data-title="Define units and methods in the metadata.">parameter</th>
<th data-title="Only numeric data or NA for missing values.">value</th>
<th data-title="Numeric QC flag codes with definitions in metadata.">flag</th>
<th class="optional-column" data-title="Avoid if possible! All quality information should be encoded as flags. Notes can still be used to designate interesting observations.">notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>YYYY-MM-DD<br><span style="color: #a9a9a9">hh:mm:ss</span></td>
<td>character</td>
<td style="color: #a9a9a9">character</td>
<td>character<br><span class="subparen">(consider <a href="https://csdms.colorado.edu/wiki/CSN_Searchable_List-Names" style="color: darkblue">CSDMS standard names</a>)</span></td>
<td>numeric</td>
<td>integer</td>
<td style="color: #a9a9a9">character</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<h4>Specific example</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th class="spec-cell" data-title="Timezone defined in metadata: UTC">datetime</th>
<th class="spec-cell" data-title="Coordinates, CRS, elevation, description defined in metadata">site_code</th>
<th class="spec-cell" data-title="Methods and parameter names defined in metadata">parameter</th>
<th class="spec-cell" data-title="Units defined in metadata. Missing value code NA defined in metadata.">value</th>
<th class="spec-cell" data-title="Flag codes defined in metadata">flag</th>
</tr>
</thead>
<tbody>
<tr>
<td>2016-01-01 00:00:00</td>
<td>salinas1</td>
<td>spec_cond</td>
<td>9.40</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:00:00</td>
<td>salinas1</td>
<td>nitrate</td>
<td>1.81</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:15:00</td>
<td>salinas1</td>
<td>spec_cond</td>
<td>9.43</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:15:00</td>
<td>salinas1</td>
<td>nitrate</td>
<td class="td-titled" data-title='Use NA to designate missing values.'>NA</td>
<td></td>
</tr>
<tr>
<td>2016-01-01 00:30:00</td>
<td>salinas1</td>
<td>spec_cond</td>
<td>0.01</td>
<td class="td-titled" data-title='Code 310 defined in metadata: "below detection limit; estimated as 1/2 detection limit"'>310</td>
</tr>
<tr>
<td>2016-01-01 00:30:00</td>
<td>salinas1</td>
<td>nitrate</td>
<td>1.82</td>
<td></td>
</tr>
<tr>
<td colspan="5" style="text-align: center; border: none;">...</td>
</tr>
<tr>
<td>2023-12-31 23:45:00</td>
<td class="td-titled" data-title='Best to include all sites in the same file. Fewer files is better!'>nacimiento3</td>
<td>spec_cond</td>
<td>7.44</td>
<td></td>
</tr>
<tr>
<td>2023-12-31 23:45:00</td>
<td class="td-titled" data-title='Best to include all sites in the same file. Fewer files is better!'>nacimiento3</td>
<td>nitrate</td>
<td>0.05</td>
<td class="td-titled" data-title='Code 311 defined in metadata: "sensor out of water"'>311</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
</div>
<hr>
<h4>General guidelines</h4>
<ul>
<li>Use CSV files. <span class="lite">They're plain text, all data software can handle them, and they'll never stop working.</span></li>
<li><span class="lite">If in doubt, use</span> UTF-8 encoding.</li>
<li>Maximum filesize: 2 GB. <span class="lite">Data may take up extra space when represented in a program like R or Excel, and 4-8 GB of memory is still common.</lite>
<li><span class="lite">Represent missing data with </span>NA<span class="lite">. Environmental data is primarily processed in R or Python (pandas), both of which recognize NA as a missing value. Julia does too. Excel expects an empty cell, but empty cells can't always be described with metadata. Matlab expects NaN, and SAS/SPSS expect a period, but can easily be told to expect NA instead.</span>
<li>Wide format <span class="lite">is better for human reading and machine analysis. Use it when you can. If wide format results in a lot of missing data, use long.</span></li>
<li><span class="lite">Publish your data to a </span>data repository<span class="lite">. We recommend <a href="https://portal.edirepository.org/nis/home.jsp">EDI</a>, but there are many others.</span>
<ul class="lite">
<li><a href="https://portal.edirepository.org/nis/home.jsp">EDI: Environmental Data Initiative</a> (robust metadata)</li>
<ul>
<li><a href="https://github.com/EDIorg/EMLassemblyline">EMLassemblyline</a>: a tool for building metadata with code</li>
<li><a href="https://ezeml.edirepository.org/eml/auth/login">ezEML</a>: a tool for building metadata with forms</li>
<li><a href="https://github.com/earnaud/MetaShARK-v2">MetaShARK</a>: another graphical tool</li>
</ul>
<li><a href="https://www.hydroshare.org/">HydroShare</a> (hydro-focus)</li>
<li><a href="https://www.pangaea.de/">Pangaea</a> (georeferenced)</li>
<li><a href="https://datadryad.org/stash">Dryad</a>, <a href="https://figshare.com/">Figshare</a>, and <a href="https://zenodo.org/">Zenodo</a> (general)</li>
</ul>
<li><span class="lite">Use </span>Creative Commons licenses<span class="lite">.</span></li>
<ul class="lite">
<li><a href="https://creativecommons.org/licenses/by/4.0/?ref=chooser-v1">CC BY 4.0</a> is the gold standard. It requires attribution and nothing more. <a href="https://creativecommons.org/publicdomain/zero/1.0/?ref=chooser-v1">CC0 1.0</a> puts your data in the public domain.</a></li>
<li>There are CC licenses that prevent commercial use and derivative products, but note that these are not compatible with <a href="https://okfn.org/en/library/what-is-open/">"open data"</a>.</li>
<li>Use this <a href="https://chooser-beta.creativecommons.org/">license chooser</a> if you're not sure.</li>
</ul>
<li><span class="lite">For long-term datasets, maintain a</span> consistent file design<span class="lite"> through time, only changing it when necessary. Programs written to parse your data may break any time you add columns or flag codes, change the filename, etc.</span></li>
<li>Filenames <span class="lite">should be simple and general, like water_quality.csv. For datasets that could receive updates, the filename should not include time information. Versioning should be handled by your data repository, so no need to include the version in the filename.</span></li>
</ul>
<br>
<div class="d-flex justify-content-center align-items-center">
<div style="text-center">
<a href="https://macrosheds.org">
<img src="logo.png" alt="MacroSheds Logo" style="height: 50px;">
</a>
</div>
</div>
</br>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$('th, .td-titled').on('mouseenter touchstart', function(e) {
// Prevent default action for touchstart
if(e.type === 'touchstart') {
e.preventDefault();
}
// Check if tooltip is already shown for this element
if ($(this).data('tooltip-active')) {
return; // Tooltip already active, ignore hover/touch
}
// Set tooltip as active
$(this).data('tooltip-active', true);
var title = $(this).data('title');
var tooltip = $('<div class="tooltip"></div>').text(title).appendTo('body');
var offset = $(this).offset();
tooltip.css({
top: offset.top - tooltip.outerHeight() - 5,
left: offset.left,
position: 'absolute',
opacity: 1 // Ensure it's fully visible
});
}).on('mouseleave touchend', function() {
// Set tooltip as inactive
$(this).data('tooltip-active', false);
$('.tooltip').remove();
});
});
// Remove the tooltip on click anywhere in the document
$(document).click(function(e) {
if (!$(e.target).closest('.tooltip').length) {
$('.tooltip').remove();
}
});
</script>
</body>
</html>