Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 4x 8x 8x 8x 8x 8x 16x 8x 16x 16x 16x 16x 16x 16x 24x 16x 16x 16x 16x 16x 8x 4x 24x 24x 24x 24x 24x 48x 24x 24x 44x 44x 72x 72x 72x 72x 72x 72x 44x 28x 12x 72x 44x 24x 4x 4x 4x 4x 8x 4x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 4x 4x 4x 8x 4x | import DataHandler from './index' import {Entity, Features} from '../types' export function tall( this: DataHandler, entity: Entity, time_range: number[], feats: Features, vars: string[], sep: string ): string { if (entity.group in this.meta.times) { const op: string[] = [], time = this.meta.times[entity.group].value as number[] let tr = '' Object.keys(feats).forEach(f => { tr += '"' + entity.features[feats[f]] + '"' + sep }) vars.forEach(k => { const vc = entity.variables[k].code if (vc in entity.data) { const range: [number, number] = this.meta.variables[entity.group][k].time_range let r = '' const yn = time_range[1] + 1 for (let y = time_range[0]; y < yn; y++) { if (y >= range[0] && y <= range[1]) { const vec = entity.data[vc] const value = Array.isArray(vec) ? vec[y - range[0]] : vec if (!isNaN(value)) { r += (r ? '\n' : '') + tr + time[y] + sep + '"' + k + '"' + sep + value } } } if (r) op.push(r) } }) return op.join('\n') } return '' } export function mixed( this: DataHandler, entity: Entity, time_range: number[], feats: Features, vars: string[], sep: string ): string { if (entity.group in this.meta.times) { const op: string[] = [], time = this.meta.times[entity.group].value as number[] let tr = '' Object.keys(feats).forEach(f => { tr += '"' + entity.features[feats[f]] + '"' + sep }) const yn = time_range[1] + 1 for (let y = time_range[0]; y < yn; y++) { let r = tr + time[y] vars.forEach((k: string) => { const vc = entity.variables[k].code if (vc in entity.data) { const trange = this.meta.variables[entity.group][k].time_range const vec = entity.data[vc] let value = NaN if (Array.isArray(vec)) { if (y >= trange[0] && y <= trange[1]) value = vec[y - trange[0]] } else if (y === trange[0]) { value = vec } r += sep + (isNaN(value) ? 'NA' : value) } else Er += sep + 'NA' }) op.push(r) } return op.join('\n') } return '' } export function wide( this: DataHandler, entity: Entity, time_range: number[], feats: Features, vars: string[], sep: string ): string { if (entity.group in this.meta.times) { let r = '' Object.keys(feats).forEach(f => { r += (r ? sep : '') + '"' + entity.features[feats[f]] + '"' }) vars.forEach(k => { const vc = entity.variables[k].code const range: [number, number] = this.meta.ranges[k] const trange: [number, number] = this.meta.variables[entity.group][k].time_range const yn = time_range[1] + 1 for (let y = time_range[0]; y < yn; y++) { if (y >= range[0] && y <= range[1]) { if (vc in entity.data) { const vec = entity.data[vc] let value = NaN if (Array.isArray(vec)) { if (y >= trange[0] && y <= trange[1]) value = vec[y - trange[0]] } else if (y === trange[0]) { value = vec } r += sep + (isNaN(value) ? 'NA' : value) } else Er += sep + 'NA' } } }) return r } return '' } |