http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/colortables.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/colortables.py b/analysis/webservice/algorithms/colortables.py index ff24929..7215db9 100644 --- a/analysis/webservice/algorithms/colortables.py +++ b/analysis/webservice/algorithms/colortables.py @@ -4,532 +4,531 @@ grayscale = [ ] oceanography = [ - [2, 3, 206], - [143, 226, 255], - [255, 255, 255], - [255, 241, 27], - [253, 0, 0] - ] + [2, 3, 206], + [143, 226, 255], + [255, 255, 255], + [255, 241, 27], + [253, 0, 0] +] rainbow = [ - [125, 0, 255], - [0, 0, 255], - [0, 255, 0], - [255, 255, 0], - [255, 125, 0], - [255, 0, 0] - ] + [125, 0, 255], + [0, 0, 255], + [0, 255, 0], + [255, 255, 0], + [255, 125, 0], + [255, 0, 0] +] anomaly = [ - [129, 31, 240], - [124, 30, 240], - [119, 29, 241], - [114, 27, 242], - [108, 26, 242], - [103, 24, 243], - [97, 23, 244], - [91, 21, 245], - [86, 20, 245], - [80, 18, 246], - [73, 17, 247], - [67, 15, 247], - [61, 14, 248], - [55, 12, 249], - [48, 11, 250], - [42, 9, 250], - [35, 7, 251], - [28, 6, 252], - [21, 4, 252], - [14, 3, 253], - [7, 1, 254], - [0, 0, 255], - [3, 6, 253], - [6, 12, 252], - [10, 18, 250], - [13, 24, 249], - [17, 30, 247], - [20, 36, 246], - [23, 42, 245], - [26, 47, 243], - [29, 52, 242], - [33, 57, 240], - [36, 62, 239], - [39, 67, 237], - [42, 72, 236], - [45, 76, 235], - [48, 81, 233], - [51, 85, 232], - [53, 89, 230], - [56, 93, 229], - [59, 97, 227], - [62, 101, 226], - [65, 105, 225], - [63, 106, 226], - [62, 107, 227], - [60, 108, 229], - [59, 110, 230], - [57, 111, 232], - [56, 113, 233], - [54, 115, 235], - [52, 116, 236], - [51, 118, 237], - [49, 120, 239], - [47, 122, 240], - [46, 123, 242], - [44, 125, 243], - [42, 127, 245], - [41, 130, 246], - [39, 132, 247], - [37, 134, 249], - [35, 136, 250], - [33, 139, 252], - [31, 141, 253], - [29, 144, 255], - [28, 145, 255], - [27, 147, 255], - [25, 149, 255], - [24, 151, 255], - [22, 153, 255], - [21, 155, 255], - [19, 158, 255], - [18, 160, 255], - [17, 162, 255], - [15, 164, 255], - [14, 166, 255], - [12, 169, 255], - [11, 171, 255], - [9, 173, 255], - [8, 176, 255], - [7, 178, 255], - [5, 180, 255], - [4, 183, 255], - [2, 185, 255], - [1, 188, 255], - [0, 191, 255], - [7, 191, 254], - [14, 191, 253], - [21, 191, 252], - [28, 191, 251], - [35, 192, 251], - [41, 192, 250], - [48, 193, 249], - [55, 193, 248], - [62, 194, 248], - [69, 194, 247], - [75, 195, 246], - [82, 196, 245], - [88, 196, 245], - [95, 197, 244], - [101, 198, 243], - [108, 199, 242], - [114, 200, 242], - [121, 201, 241], - [127, 202, 240], - [133, 203, 239], - [140, 205, 239], - [143, 206, 239], - [146, 208, 239], - [149, 209, 240], - [152, 211, 240], - [155, 212, 241], - [158, 214, 241], - [161, 215, 242], - [164, 217, 242], - [168, 218, 243], - [171, 220, 243], - [174, 221, 244], - [177, 222, 244], - [180, 224, 245], - [184, 225, 245], - [187, 227, 246], - [190, 228, 246], - [193, 230, 247], - [197, 231, 247], - [200, 233, 248], - [203, 234, 248], - [207, 236, 249], - [255, 255, 200], - [255, 254, 192], - [255, 254, 185], - [255, 253, 178], - [255, 252, 171], - [255, 251, 164], - [255, 250, 157], - [255, 249, 149], - [255, 248, 142], - [255, 247, 135], - [255, 246, 128], - [255, 244, 121], - [255, 243, 114], - [255, 241, 107], - [255, 239, 99], - [255, 238, 92], - [255, 236, 85], - [255, 234, 78], - [255, 231, 71], - [255, 229, 64], - [255, 227, 57], - [255, 225, 49], - [255, 222, 47], - [255, 220, 45], - [255, 218, 42], - [255, 215, 40], - [255, 213, 38], - [255, 211, 35], - [255, 208, 33], - [255, 206, 30], - [255, 203, 28], - [255, 201, 26], - [255, 198, 23], - [255, 195, 21], - [255, 193, 19], - [255, 190, 16], - [255, 187, 14], - [255, 184, 11], - [255, 181, 9], - [255, 179, 7], - [255, 176, 4], - [255, 173, 2], - [255, 170, 0], - [255, 167, 0], - [255, 164, 0], - [255, 161, 0], - [255, 158, 0], - [255, 155, 0], - [255, 152, 0], - [255, 149, 0], - [255, 147, 0], - [255, 144, 0], - [255, 141, 0], - [255, 138, 0], - [255, 135, 0], - [255, 132, 0], - [255, 129, 0], - [255, 127, 0], - [255, 124, 0], - [255, 121, 0], - [255, 118, 0], - [255, 115, 0], - [255, 112, 0], - [255, 110, 0], - [255, 104, 0], - [255, 99, 0], - [255, 94, 0], - [255, 89, 0], - [255, 83, 0], - [255, 78, 0], - [255, 73, 0], - [255, 68, 0], - [255, 62, 0], - [255, 57, 0], - [255, 52, 0], - [255, 47, 0], - [255, 41, 0], - [255, 36, 0], - [255, 31, 0], - [255, 26, 0], - [255, 20, 0], - [255, 15, 0], - [255, 10, 0], - [255, 5, 0], - [255, 0, 0], - [252, 0, 0], - [249, 0, 0], - [247, 0, 0], - [244, 0, 0], - [241, 0, 0], - [239, 0, 0], - [236, 0, 0], - [234, 0, 0], - [231, 0, 0], - [228, 0, 0], - [226, 0, 0], - [223, 0, 0], - [220, 0, 0], - [218, 0, 0], - [215, 0, 0], - [213, 0, 0], - [210, 0, 0], - [207, 0, 0], - [205, 0, 0], - [202, 0, 0], - [200, 0, 0], - [202, 6, 6], - [205, 13, 13], - [207, 20, 20], - [210, 27, 27], - [213, 35, 35], - [215, 43, 43], - [218, 50, 50], - [220, 58, 58], - [223, 66, 66], - [226, 75, 75], - [228, 83, 83], - [231, 92, 92], - [234, 101, 101], - [236, 110, 110], - [239, 119, 119], - [241, 128, 128], - [244, 138, 138], - [247, 147, 147], - [249, 157, 157], - [252, 167, 167], - [255, 178, 178] - ] + [129, 31, 240], + [124, 30, 240], + [119, 29, 241], + [114, 27, 242], + [108, 26, 242], + [103, 24, 243], + [97, 23, 244], + [91, 21, 245], + [86, 20, 245], + [80, 18, 246], + [73, 17, 247], + [67, 15, 247], + [61, 14, 248], + [55, 12, 249], + [48, 11, 250], + [42, 9, 250], + [35, 7, 251], + [28, 6, 252], + [21, 4, 252], + [14, 3, 253], + [7, 1, 254], + [0, 0, 255], + [3, 6, 253], + [6, 12, 252], + [10, 18, 250], + [13, 24, 249], + [17, 30, 247], + [20, 36, 246], + [23, 42, 245], + [26, 47, 243], + [29, 52, 242], + [33, 57, 240], + [36, 62, 239], + [39, 67, 237], + [42, 72, 236], + [45, 76, 235], + [48, 81, 233], + [51, 85, 232], + [53, 89, 230], + [56, 93, 229], + [59, 97, 227], + [62, 101, 226], + [65, 105, 225], + [63, 106, 226], + [62, 107, 227], + [60, 108, 229], + [59, 110, 230], + [57, 111, 232], + [56, 113, 233], + [54, 115, 235], + [52, 116, 236], + [51, 118, 237], + [49, 120, 239], + [47, 122, 240], + [46, 123, 242], + [44, 125, 243], + [42, 127, 245], + [41, 130, 246], + [39, 132, 247], + [37, 134, 249], + [35, 136, 250], + [33, 139, 252], + [31, 141, 253], + [29, 144, 255], + [28, 145, 255], + [27, 147, 255], + [25, 149, 255], + [24, 151, 255], + [22, 153, 255], + [21, 155, 255], + [19, 158, 255], + [18, 160, 255], + [17, 162, 255], + [15, 164, 255], + [14, 166, 255], + [12, 169, 255], + [11, 171, 255], + [9, 173, 255], + [8, 176, 255], + [7, 178, 255], + [5, 180, 255], + [4, 183, 255], + [2, 185, 255], + [1, 188, 255], + [0, 191, 255], + [7, 191, 254], + [14, 191, 253], + [21, 191, 252], + [28, 191, 251], + [35, 192, 251], + [41, 192, 250], + [48, 193, 249], + [55, 193, 248], + [62, 194, 248], + [69, 194, 247], + [75, 195, 246], + [82, 196, 245], + [88, 196, 245], + [95, 197, 244], + [101, 198, 243], + [108, 199, 242], + [114, 200, 242], + [121, 201, 241], + [127, 202, 240], + [133, 203, 239], + [140, 205, 239], + [143, 206, 239], + [146, 208, 239], + [149, 209, 240], + [152, 211, 240], + [155, 212, 241], + [158, 214, 241], + [161, 215, 242], + [164, 217, 242], + [168, 218, 243], + [171, 220, 243], + [174, 221, 244], + [177, 222, 244], + [180, 224, 245], + [184, 225, 245], + [187, 227, 246], + [190, 228, 246], + [193, 230, 247], + [197, 231, 247], + [200, 233, 248], + [203, 234, 248], + [207, 236, 249], + [255, 255, 200], + [255, 254, 192], + [255, 254, 185], + [255, 253, 178], + [255, 252, 171], + [255, 251, 164], + [255, 250, 157], + [255, 249, 149], + [255, 248, 142], + [255, 247, 135], + [255, 246, 128], + [255, 244, 121], + [255, 243, 114], + [255, 241, 107], + [255, 239, 99], + [255, 238, 92], + [255, 236, 85], + [255, 234, 78], + [255, 231, 71], + [255, 229, 64], + [255, 227, 57], + [255, 225, 49], + [255, 222, 47], + [255, 220, 45], + [255, 218, 42], + [255, 215, 40], + [255, 213, 38], + [255, 211, 35], + [255, 208, 33], + [255, 206, 30], + [255, 203, 28], + [255, 201, 26], + [255, 198, 23], + [255, 195, 21], + [255, 193, 19], + [255, 190, 16], + [255, 187, 14], + [255, 184, 11], + [255, 181, 9], + [255, 179, 7], + [255, 176, 4], + [255, 173, 2], + [255, 170, 0], + [255, 167, 0], + [255, 164, 0], + [255, 161, 0], + [255, 158, 0], + [255, 155, 0], + [255, 152, 0], + [255, 149, 0], + [255, 147, 0], + [255, 144, 0], + [255, 141, 0], + [255, 138, 0], + [255, 135, 0], + [255, 132, 0], + [255, 129, 0], + [255, 127, 0], + [255, 124, 0], + [255, 121, 0], + [255, 118, 0], + [255, 115, 0], + [255, 112, 0], + [255, 110, 0], + [255, 104, 0], + [255, 99, 0], + [255, 94, 0], + [255, 89, 0], + [255, 83, 0], + [255, 78, 0], + [255, 73, 0], + [255, 68, 0], + [255, 62, 0], + [255, 57, 0], + [255, 52, 0], + [255, 47, 0], + [255, 41, 0], + [255, 36, 0], + [255, 31, 0], + [255, 26, 0], + [255, 20, 0], + [255, 15, 0], + [255, 10, 0], + [255, 5, 0], + [255, 0, 0], + [252, 0, 0], + [249, 0, 0], + [247, 0, 0], + [244, 0, 0], + [241, 0, 0], + [239, 0, 0], + [236, 0, 0], + [234, 0, 0], + [231, 0, 0], + [228, 0, 0], + [226, 0, 0], + [223, 0, 0], + [220, 0, 0], + [218, 0, 0], + [215, 0, 0], + [213, 0, 0], + [210, 0, 0], + [207, 0, 0], + [205, 0, 0], + [202, 0, 0], + [200, 0, 0], + [202, 6, 6], + [205, 13, 13], + [207, 20, 20], + [210, 27, 27], + [213, 35, 35], + [215, 43, 43], + [218, 50, 50], + [220, 58, 58], + [223, 66, 66], + [226, 75, 75], + [228, 83, 83], + [231, 92, 92], + [234, 101, 101], + [236, 110, 110], + [239, 119, 119], + [241, 128, 128], + [244, 138, 138], + [247, 147, 147], + [249, 157, 157], + [252, 167, 167], + [255, 178, 178] +] hottemp = [ - [255, 255, 255], - [255, 255, 0], - [255, 0, 0], - [0, 0, 0], - [0, 0, 0] - ] + [255, 255, 255], + [255, 255, 0], + [255, 0, 0], + [0, 0, 0], + [0, 0, 0] +] anomaly2 = [ - [129, 31, 240], - [124, 30, 240], - [119, 29, 241], - [114, 27, 242], - [108, 26, 242], - [103, 24, 243], - [97, 23, 244], - [91, 21, 245], - [86, 20, 245], - [80, 18, 246], - [73, 17, 247], - [67, 15, 247], - [61, 14, 248], - [55, 12, 249], - [48, 11, 250], - [42, 9, 250], - [35, 7, 251], - [28, 6, 252], - [21, 4, 252], - [14, 3, 253], - [7, 1, 254], - [0, 0, 255], - [3, 6, 253], - [6, 12, 252], - [10, 18, 250], - [13, 24, 249], - [17, 30, 247], - [20, 36, 246], - [23, 42, 245], - [26, 47, 243], - [29, 52, 242], - [33, 57, 240], - [36, 62, 239], - [39, 67, 237], - [42, 72, 236], - [45, 76, 235], - [48, 81, 233], - [51, 85, 232], - [53, 89, 230], - [56, 93, 229], - [59, 97, 227], - [62, 101, 226], - [65, 105, 225], - [63, 106, 226], - [62, 107, 227], - [60, 108, 229], - [59, 110, 230], - [57, 111, 232], - [56, 113, 233], - [54, 115, 235], - [52, 116, 236], - [51, 118, 237], - [49, 120, 239], - [47, 122, 240], - [46, 123, 242], - [44, 125, 243], - [42, 127, 245], - [41, 130, 246], - [39, 132, 247], - [37, 134, 249], - [35, 136, 250], - [33, 139, 252], - [31, 141, 253], - [29, 144, 255], - [28, 145, 255], - [27, 147, 255], - [25, 149, 255], - [24, 151, 255], - [22, 153, 255], - [21, 155, 255], - [19, 158, 255], - [18, 160, 255], - [17, 162, 255], - [15, 164, 255], - [14, 166, 255], - [12, 169, 255], - [11, 171, 255], - [9, 173, 255], - [8, 176, 255], - [7, 178, 255], - [5, 180, 255], - [4, 183, 255], - [2, 185, 255], - [1, 188, 255], - [0, 191, 255], - [7, 191, 254], - [14, 191, 253], - [21, 191, 252], - [28, 191, 251], - [35, 192, 251], - [41, 192, 250], - [48, 193, 249], - [55, 193, 248], - [62, 194, 248], - [69, 194, 247], - [75, 195, 246], - [82, 196, 245], - [88, 196, 245], - [95, 197, 244], - [101, 198, 243], - [108, 199, 242], - [114, 200, 242], - [121, 201, 241], - [127, 202, 240], - [133, 203, 239], - [140, 205, 239], - [143, 206, 239], - [146, 208, 239], - [149, 209, 240], - [152, 211, 240], - [155, 212, 241], - [158, 214, 241], - [161, 215, 242], - [164, 217, 242], - [168, 218, 243], - [171, 220, 243], - [174, 221, 244], - [177, 222, 244], - [180, 224, 245], - [184, 225, 245], - [187, 227, 246], - [190, 228, 246], - [193, 230, 247], - [197, 231, 247], - [200, 233, 248], - [203, 234, 248], - [207, 236, 249], - [255, 255, 255], - [255, 255, 255], - [255, 255, 200], - [255, 254, 192], - [255, 254, 185], - [255, 253, 178], - [255, 252, 171], - [255, 251, 164], - [255, 250, 157], - [255, 249, 149], - [255, 248, 142], - [255, 247, 135], - [255, 246, 128], - [255, 244, 121], - [255, 243, 114], - [255, 241, 107], - [255, 239, 99], - [255, 238, 92], - [255, 236, 85], - [255, 234, 78], - [255, 231, 71], - [255, 229, 64], - [255, 227, 57], - [255, 225, 49], - [255, 222, 47], - [255, 220, 45], - [255, 218, 42], - [255, 215, 40], - [255, 213, 38], - [255, 211, 35], - [255, 208, 33], - [255, 206, 30], - [255, 203, 28], - [255, 201, 26], - [255, 198, 23], - [255, 195, 21], - [255, 193, 19], - [255, 190, 16], - [255, 187, 14], - [255, 184, 11], - [255, 181, 9], - [255, 179, 7], - [255, 176, 4], - [255, 173, 2], - [255, 170, 0], - [255, 167, 0], - [255, 164, 0], - [255, 161, 0], - [255, 158, 0], - [255, 155, 0], - [255, 152, 0], - [255, 149, 0], - [255, 147, 0], - [255, 144, 0], - [255, 141, 0], - [255, 138, 0], - [255, 135, 0], - [255, 132, 0], - [255, 129, 0], - [255, 127, 0], - [255, 124, 0], - [255, 121, 0], - [255, 118, 0], - [255, 115, 0], - [255, 112, 0], - [255, 110, 0], - [255, 104, 0], - [255, 99, 0], - [255, 94, 0], - [255, 89, 0], - [255, 83, 0], - [255, 78, 0], - [255, 73, 0], - [255, 68, 0], - [255, 62, 0], - [255, 57, 0], - [255, 52, 0], - [255, 47, 0], - [255, 41, 0], - [255, 36, 0], - [255, 31, 0], - [255, 26, 0], - [255, 20, 0], - [255, 15, 0], - [255, 10, 0], - [255, 5, 0], - [255, 0, 0], - [252, 0, 0], - [249, 0, 0], - [247, 0, 0], - [244, 0, 0], - [241, 0, 0], - [239, 0, 0], - [236, 0, 0], - [234, 0, 0], - [231, 0, 0], - [228, 0, 0], - [226, 0, 0], - [223, 0, 0], - [220, 0, 0], - [218, 0, 0], - [215, 0, 0], - [213, 0, 0], - [210, 0, 0], - [207, 0, 0], - [205, 0, 0], - [202, 0, 0], - [200, 0, 0], - [200, 6, 6] - ] - + [129, 31, 240], + [124, 30, 240], + [119, 29, 241], + [114, 27, 242], + [108, 26, 242], + [103, 24, 243], + [97, 23, 244], + [91, 21, 245], + [86, 20, 245], + [80, 18, 246], + [73, 17, 247], + [67, 15, 247], + [61, 14, 248], + [55, 12, 249], + [48, 11, 250], + [42, 9, 250], + [35, 7, 251], + [28, 6, 252], + [21, 4, 252], + [14, 3, 253], + [7, 1, 254], + [0, 0, 255], + [3, 6, 253], + [6, 12, 252], + [10, 18, 250], + [13, 24, 249], + [17, 30, 247], + [20, 36, 246], + [23, 42, 245], + [26, 47, 243], + [29, 52, 242], + [33, 57, 240], + [36, 62, 239], + [39, 67, 237], + [42, 72, 236], + [45, 76, 235], + [48, 81, 233], + [51, 85, 232], + [53, 89, 230], + [56, 93, 229], + [59, 97, 227], + [62, 101, 226], + [65, 105, 225], + [63, 106, 226], + [62, 107, 227], + [60, 108, 229], + [59, 110, 230], + [57, 111, 232], + [56, 113, 233], + [54, 115, 235], + [52, 116, 236], + [51, 118, 237], + [49, 120, 239], + [47, 122, 240], + [46, 123, 242], + [44, 125, 243], + [42, 127, 245], + [41, 130, 246], + [39, 132, 247], + [37, 134, 249], + [35, 136, 250], + [33, 139, 252], + [31, 141, 253], + [29, 144, 255], + [28, 145, 255], + [27, 147, 255], + [25, 149, 255], + [24, 151, 255], + [22, 153, 255], + [21, 155, 255], + [19, 158, 255], + [18, 160, 255], + [17, 162, 255], + [15, 164, 255], + [14, 166, 255], + [12, 169, 255], + [11, 171, 255], + [9, 173, 255], + [8, 176, 255], + [7, 178, 255], + [5, 180, 255], + [4, 183, 255], + [2, 185, 255], + [1, 188, 255], + [0, 191, 255], + [7, 191, 254], + [14, 191, 253], + [21, 191, 252], + [28, 191, 251], + [35, 192, 251], + [41, 192, 250], + [48, 193, 249], + [55, 193, 248], + [62, 194, 248], + [69, 194, 247], + [75, 195, 246], + [82, 196, 245], + [88, 196, 245], + [95, 197, 244], + [101, 198, 243], + [108, 199, 242], + [114, 200, 242], + [121, 201, 241], + [127, 202, 240], + [133, 203, 239], + [140, 205, 239], + [143, 206, 239], + [146, 208, 239], + [149, 209, 240], + [152, 211, 240], + [155, 212, 241], + [158, 214, 241], + [161, 215, 242], + [164, 217, 242], + [168, 218, 243], + [171, 220, 243], + [174, 221, 244], + [177, 222, 244], + [180, 224, 245], + [184, 225, 245], + [187, 227, 246], + [190, 228, 246], + [193, 230, 247], + [197, 231, 247], + [200, 233, 248], + [203, 234, 248], + [207, 236, 249], + [255, 255, 255], + [255, 255, 255], + [255, 255, 200], + [255, 254, 192], + [255, 254, 185], + [255, 253, 178], + [255, 252, 171], + [255, 251, 164], + [255, 250, 157], + [255, 249, 149], + [255, 248, 142], + [255, 247, 135], + [255, 246, 128], + [255, 244, 121], + [255, 243, 114], + [255, 241, 107], + [255, 239, 99], + [255, 238, 92], + [255, 236, 85], + [255, 234, 78], + [255, 231, 71], + [255, 229, 64], + [255, 227, 57], + [255, 225, 49], + [255, 222, 47], + [255, 220, 45], + [255, 218, 42], + [255, 215, 40], + [255, 213, 38], + [255, 211, 35], + [255, 208, 33], + [255, 206, 30], + [255, 203, 28], + [255, 201, 26], + [255, 198, 23], + [255, 195, 21], + [255, 193, 19], + [255, 190, 16], + [255, 187, 14], + [255, 184, 11], + [255, 181, 9], + [255, 179, 7], + [255, 176, 4], + [255, 173, 2], + [255, 170, 0], + [255, 167, 0], + [255, 164, 0], + [255, 161, 0], + [255, 158, 0], + [255, 155, 0], + [255, 152, 0], + [255, 149, 0], + [255, 147, 0], + [255, 144, 0], + [255, 141, 0], + [255, 138, 0], + [255, 135, 0], + [255, 132, 0], + [255, 129, 0], + [255, 127, 0], + [255, 124, 0], + [255, 121, 0], + [255, 118, 0], + [255, 115, 0], + [255, 112, 0], + [255, 110, 0], + [255, 104, 0], + [255, 99, 0], + [255, 94, 0], + [255, 89, 0], + [255, 83, 0], + [255, 78, 0], + [255, 73, 0], + [255, 68, 0], + [255, 62, 0], + [255, 57, 0], + [255, 52, 0], + [255, 47, 0], + [255, 41, 0], + [255, 36, 0], + [255, 31, 0], + [255, 26, 0], + [255, 20, 0], + [255, 15, 0], + [255, 10, 0], + [255, 5, 0], + [255, 0, 0], + [252, 0, 0], + [249, 0, 0], + [247, 0, 0], + [244, 0, 0], + [241, 0, 0], + [239, 0, 0], + [236, 0, 0], + [234, 0, 0], + [231, 0, 0], + [228, 0, 0], + [226, 0, 0], + [223, 0, 0], + [220, 0, 0], + [218, 0, 0], + [215, 0, 0], + [213, 0, 0], + [210, 0, 0], + [207, 0, 0], + [205, 0, 0], + [202, 0, 0], + [200, 0, 0], + [200, 6, 6] +] smap = [ - [125, 0, 255], - [0, 0, 255], - [0 , 255, 0], - [255, 255, 0], - [255, 125, 0], - [255, 0, 0] - ] + [125, 0, 255], + [0, 0, 255], + [0, 255, 0], + [255, 255, 0], + [255, 125, 0], + [255, 0, 0] +]
http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/BaseDomsHandler.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/BaseDomsHandler.py b/analysis/webservice/algorithms/doms/BaseDomsHandler.py index cc4d654..75a4488 100644 --- a/analysis/webservice/algorithms/doms/BaseDomsHandler.py +++ b/analysis/webservice/algorithms/doms/BaseDomsHandler.py @@ -2,9 +2,9 @@ import StringIO import csv import json from datetime import datetime +from decimal import Decimal import numpy as np -from decimal import Decimal from pytz import timezone, UTC import config http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/DatasetListQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/DatasetListQuery.py b/analysis/webservice/algorithms/doms/DatasetListQuery.py index 4a08517..d7ee101 100644 --- a/analysis/webservice/algorithms/doms/DatasetListQuery.py +++ b/analysis/webservice/algorithms/doms/DatasetListQuery.py @@ -1,19 +1,18 @@ -from webservice.NexusHandler import NexusHandler as BaseHandler -from webservice.webmodel import StatsComputeOptions -from webservice.NexusHandler import nexus_handler -from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC -from webservice.webmodel import NexusResults, NexusProcessingException, DatasetNotFoundException, cached +import json +import traceback + +import requests + import BaseDomsHandler -import datafetch import config -import requests -import json import values -import traceback +from webservice.NexusHandler import NexusHandler as BaseHandler +from webservice.NexusHandler import nexus_handler +from webservice.webmodel import cached + @nexus_handler class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): - name = "DOMS Dataset Listing" path = "/domslist" description = "" @@ -23,7 +22,6 @@ class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): def __init__(self): BaseHandler.__init__(self) - def getFacetsForInsituSource(self, source): url = source["url"] @@ -47,11 +45,10 @@ class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): value["value"] = values.getDescByListNameAndId(field, int(value["value"])) return depths, results["facets"] - except: # KMG: Don't eat the exception. Add better handling... + except: # KMG: Don't eat the exception. Add better handling... traceback.print_exc() return None, None - def getMetadataUrlForDataset(self, dataset): datasetSpec = config.getEndpointByName(dataset) if datasetSpec is not None: @@ -66,7 +63,7 @@ class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): elif dataset == "AVHRR_OI_L4_GHRSST_NCEI" or dataset == "AVHRR_OI_L4_GHRSST_NCEI_CLIM": dataset = "AVHRR_OI-NCEI-L4-GLOB-v2.0" - return "http://doms.jpl.nasa.gov/ws/metadata/dataset?shortName=%s&format=umm-json"%dataset + return "http://doms.jpl.nasa.gov/ws/metadata/dataset?shortName=%s&format=umm-json" % dataset def getMetadataForSource(self, dataset): try: @@ -86,21 +83,19 @@ class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): for satellite in satellitesList: satellite["metadata"] = self.getMetadataForSource(satellite["shortName"]) - for insitu in config.ENDPOINTS: depths, facets = self.getFacetsForInsituSource(insitu) insituList.append({ - "name" : insitu["name"], - "endpoint" : insitu["url"], + "name": insitu["name"], + "endpoint": insitu["url"], "metadata": self.getMetadataForSource(insitu["name"]), "depths": depths, "facets": facets }) - values = { - "satellite" : satellitesList, - "insitu" : insituList + "satellite": satellitesList, + "insitu": insituList } return BaseDomsHandler.DomsQueryResults(results=values) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/DomsInitialization.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/DomsInitialization.py b/analysis/webservice/algorithms/doms/DomsInitialization.py index bc92ebf..70d63d1 100644 --- a/analysis/webservice/algorithms/doms/DomsInitialization.py +++ b/analysis/webservice/algorithms/doms/DomsInitialization.py @@ -5,11 +5,11 @@ California Institute of Technology. All rights reserved import ConfigParser import logging -import pkg_resources -from cassandra import InvalidRequest +import pkg_resources from cassandra.cluster import Cluster from cassandra.policies import TokenAwarePolicy, DCAwareRoundRobinPolicy + from webservice.NexusHandler import nexus_initializer http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/MatchupQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/MatchupQuery.py b/analysis/webservice/algorithms/doms/MatchupQuery.py index 8fa5d8e..0076600 100644 --- a/analysis/webservice/algorithms/doms/MatchupQuery.py +++ b/analysis/webservice/algorithms/doms/MatchupQuery.py @@ -85,7 +85,8 @@ class CombinedDomsMatchupQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): matchupSpec = self.getDataSourceByName(matchupId) if matchupSpec is not None: # Then it's in the in-situ configuration - proc = InsituDatasetProcessor(primaryContext, matchupSpec, startTime, endTime, bbox, depth_min, depth_max, + proc = InsituDatasetProcessor(primaryContext, matchupSpec, startTime, endTime, bbox, depth_min, + depth_max, platforms, timeTolerance, radiusTolerance) proc.start() else: # We assume it to be a Nexus tiled dataset http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/MetadataQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/MetadataQuery.py b/analysis/webservice/algorithms/doms/MetadataQuery.py index 4161166..648dff0 100644 --- a/analysis/webservice/algorithms/doms/MetadataQuery.py +++ b/analysis/webservice/algorithms/doms/MetadataQuery.py @@ -1,17 +1,16 @@ -from webservice.NexusHandler import NexusHandler as BaseHandler -from webservice.webmodel import StatsComputeOptions -from webservice.NexusHandler import nexus_handler -from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC -from webservice.webmodel import NexusResults, NexusProcessingException, DatasetNotFoundException +import json + +import requests + import BaseDomsHandler -import datafetch import config -import requests -import json +from webservice.NexusHandler import NexusHandler as BaseHandler +from webservice.NexusHandler import nexus_handler +from webservice.webmodel import DatasetNotFoundException + @nexus_handler class DomsMetadataQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): - name = "DOMS Metadata Listing" path = "/domsmetadata" description = "" @@ -48,4 +47,4 @@ class DomsMetadataQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): elif dataset == "SMAP_L2B_SSS": dataset = "JPL_SMAP-SSS_L2_EVAL-V2" - return "http://doms.jpl.nasa.gov/ws/metadata/dataset?shortName=%s&format=umm-json"%dataset \ No newline at end of file + return "http://doms.jpl.nasa.gov/ws/metadata/dataset?shortName=%s&format=umm-json" % dataset http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/ResultsPlotQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/ResultsPlotQuery.py b/analysis/webservice/algorithms/doms/ResultsPlotQuery.py index 2755aaf..05800f0 100644 --- a/analysis/webservice/algorithms/doms/ResultsPlotQuery.py +++ b/analysis/webservice/algorithms/doms/ResultsPlotQuery.py @@ -1,7 +1,7 @@ import BaseDomsHandler +import histogramplot import mapplot import scatterplot -import histogramplot from webservice.NexusHandler import nexus_handler http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/ResultsRetrieval.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/ResultsRetrieval.py b/analysis/webservice/algorithms/doms/ResultsRetrieval.py index 0bc1cbe..4dc982b 100644 --- a/analysis/webservice/algorithms/doms/ResultsRetrieval.py +++ b/analysis/webservice/algorithms/doms/ResultsRetrieval.py @@ -2,8 +2,8 @@ import uuid import BaseDomsHandler import ResultsStorage -from webservice.webmodel import NexusProcessingException from webservice.NexusHandler import nexus_handler +from webservice.webmodel import NexusProcessingException @nexus_handler http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/ResultsStorage.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/ResultsStorage.py b/analysis/webservice/algorithms/doms/ResultsStorage.py index c8d40f0..f4960e5 100644 --- a/analysis/webservice/algorithms/doms/ResultsStorage.py +++ b/analysis/webservice/algorithms/doms/ResultsStorage.py @@ -8,7 +8,6 @@ import logging import uuid from datetime import datetime -import numpy as np import pkg_resources from cassandra.cluster import Cluster from cassandra.policies import TokenAwarePolicy, DCAwareRoundRobinPolicy http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/StatsQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/StatsQuery.py b/analysis/webservice/algorithms/doms/StatsQuery.py index fae8639..4931e08 100644 --- a/analysis/webservice/algorithms/doms/StatsQuery.py +++ b/analysis/webservice/algorithms/doms/StatsQuery.py @@ -1,14 +1,11 @@ -from webservice.NexusHandler import NexusHandler as BaseHandler -from webservice.webmodel import StatsComputeOptions -from webservice.NexusHandler import nexus_handler -from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC -from webservice.webmodel import NexusResults, NexusProcessingException import BaseDomsHandler import datafetch +from webservice.NexusHandler import NexusHandler as BaseHandler +from webservice.NexusHandler import nexus_handler + @nexus_handler class DomsStatsQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): - name = "DOMS In-Situ Stats Lookup" path = "/domsstats" description = "" @@ -19,7 +16,6 @@ class DomsStatsQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): BaseHandler.__init__(self) def calc(self, computeOptions, **args): - source = computeOptions.get_argument("source", None) startTime = computeOptions.get_argument("s", None) endTime = computeOptions.get_argument("e", None) @@ -32,7 +28,7 @@ class DomsStatsQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): source1 = self.getDataSourceByName(source) if source1 is None: - raise Exception("Source '%s' not found"%source) + raise Exception("Source '%s' not found" % source) count, bounds = datafetch.getCount(source1, startTime, endTime, bbox, depth_min, depth_max, platforms) @@ -48,5 +44,5 @@ class DomsStatsQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): "platforms": platforms } - - return BaseDomsHandler.DomsQueryResults(results={}, args=args, details={}, bounds=bounds, count=count, computeOptions=None) \ No newline at end of file + return BaseDomsHandler.DomsQueryResults(results={}, args=args, details={}, bounds=bounds, count=count, + computeOptions=None) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/ValuesQuery.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/ValuesQuery.py b/analysis/webservice/algorithms/doms/ValuesQuery.py index 9a0f8af..1f9dc25 100644 --- a/analysis/webservice/algorithms/doms/ValuesQuery.py +++ b/analysis/webservice/algorithms/doms/ValuesQuery.py @@ -1,18 +1,17 @@ -from webservice.NexusHandler import NexusHandler as BaseHandler -from webservice.webmodel import StatsComputeOptions -from webservice.NexusHandler import nexus_handler -from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC -from webservice.webmodel import NexusResults, NexusProcessingException +from datetime import datetime + +from pytz import timezone + import BaseDomsHandler import datafetch -from pytz import timezone, UTC -from datetime import datetime +from webservice.NexusHandler import NexusHandler as BaseHandler +from webservice.NexusHandler import nexus_handler EPOCH = timezone('UTC').localize(datetime(1970, 1, 1)) + @nexus_handler class DomsValuesQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): - name = "DOMS In-Situ Value Lookup" path = "/domsvalues" description = "" @@ -23,7 +22,6 @@ class DomsValuesQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): BaseHandler.__init__(self) def calc(self, computeOptions, **args): - source = computeOptions.get_argument("source", None) startTime = computeOptions.get_start_datetime() endTime = computeOptions.get_end_datetime() @@ -36,9 +34,11 @@ class DomsValuesQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): source1 = self.getDataSourceByName(source) if source1 is None: - raise Exception("Source '%s' not found"%source) + raise Exception("Source '%s' not found" % source) - values, bounds = datafetch.getValues(source1, startTime.strftime('%Y-%m-%dT%H:%M:%SZ'), endTime.strftime('%Y-%m-%dT%H:%M:%SZ'), bbox, depth_min, depth_max, platforms, placeholders=True) + values, bounds = datafetch.getValues(source1, startTime.strftime('%Y-%m-%dT%H:%M:%SZ'), + endTime.strftime('%Y-%m-%dT%H:%M:%SZ'), bbox, depth_min, depth_max, + platforms, placeholders=True) count = len(values) args = { @@ -53,4 +53,5 @@ class DomsValuesQueryHandler(BaseDomsHandler.BaseDomsQueryHandler): "platforms": platforms } - return BaseDomsHandler.DomsQueryResults(results=values, args=args, bounds=bounds, details={}, count=count, computeOptions=None) \ No newline at end of file + return BaseDomsHandler.DomsQueryResults(results=values, args=args, bounds=bounds, details={}, count=count, + computeOptions=None) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/__init__.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/__init__.py b/analysis/webservice/algorithms/doms/__init__.py index 10f4434..97f284c 100644 --- a/analysis/webservice/algorithms/doms/__init__.py +++ b/analysis/webservice/algorithms/doms/__init__.py @@ -3,20 +3,20 @@ Copyright (c) 2016 Jet Propulsion Laboratory, California Institute of Technology. All rights reserved """ import BaseDomsHandler -import config -import datafetch import DatasetListQuery import DomsInitialization -import fetchedgeimpl -import geo import MatchupQuery import MetadataQuery import ResultsPlotQuery import ResultsRetrieval import ResultsStorage import StatsQuery -import values import ValuesQuery -import workerthread +import config +import datafetch +import fetchedgeimpl +import geo import insitusubset import subsetter +import values +import workerthread http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/datafetch.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/datafetch.py b/analysis/webservice/algorithms/doms/datafetch.py index eee6b51..5f306f1 100644 --- a/analysis/webservice/algorithms/doms/datafetch.py +++ b/analysis/webservice/algorithms/doms/datafetch.py @@ -1,6 +1,6 @@ - import fetchedgeimpl + def getCount(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms=None): return fetchedgeimpl.getCount(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms) @@ -8,6 +8,7 @@ def getCount(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms def __fetchSingleDataSource(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms=None): return fetchedgeimpl.fetch(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms) + def __fetchMultipleDataSource(endpoints, startTime, endTime, bbox, depth_min, depth_max, platforms=None): data = [] for endpoint in endpoints: @@ -15,6 +16,7 @@ def __fetchMultipleDataSource(endpoints, startTime, endTime, bbox, depth_min, de data = data + dataSingleSource return data + def fetchData(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms=None): if type(endpoint) == list: return __fetchMultipleDataSource(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms) @@ -25,5 +27,6 @@ def fetchData(endpoint, startTime, endTime, bbox, depth_min, depth_max, platform def getValues(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms=None, placeholders=False): return fetchedgeimpl.getValues(endpoint, startTime, endTime, bbox, depth_min, depth_max, platforms, placeholders) + if __name__ == "__main__": - pass \ No newline at end of file + pass http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/fetchedgeimpl.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/fetchedgeimpl.py b/analysis/webservice/algorithms/doms/fetchedgeimpl.py index d4a6c4a..87fbe0c 100644 --- a/analysis/webservice/algorithms/doms/fetchedgeimpl.py +++ b/analysis/webservice/algorithms/doms/fetchedgeimpl.py @@ -77,7 +77,8 @@ def __fetchJson(url, params, trycount=1, maxtries=5): return __fetchJson(url, params, trycount + 1, maxtries) -def __doQuery(endpoint, startTime, endTime, bbox, depth_min=None, depth_max=None, itemsPerPage=10, startIndex=0, platforms=None, +def __doQuery(endpoint, startTime, endTime, bbox, depth_min=None, depth_max=None, itemsPerPage=10, startIndex=0, + platforms=None, pageCallback=None): params = {"startTime": startTime, "endTime": endTime, "bbox": bbox, "itemsPerPage": itemsPerPage, "startIndex": startIndex, "stats": "true"} http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/geo.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/geo.py b/analysis/webservice/algorithms/doms/geo.py index ece1788..6910b33 100644 --- a/analysis/webservice/algorithms/doms/geo.py +++ b/analysis/webservice/algorithms/doms/geo.py @@ -1,6 +1,5 @@ import math - MEAN_RADIUS_EARTH_METERS = 6371010.0 EQUATORIAL_RADIUS_EARTH_METERS = 6378140.0 POLAR_RADIUS_EARTH_METERS = 6356752.0 @@ -21,12 +20,12 @@ def haversine(x0, y0, x1, y1, units=DistanceUnit.METERS): R = MEAN_RADIUS_EARTH_MILES else: raise Exception("Invalid units specified") - x0r = x0 * (math.pi / 180.0) # To radians - x1r = x1 * (math.pi / 180.0) # To radians + x0r = x0 * (math.pi / 180.0) # To radians + x1r = x1 * (math.pi / 180.0) # To radians xd = (x1 - x0) * (math.pi / 180.0) yd = (y1 - y0) * (math.pi / 180.0) - a = math.sin(xd/2.0) * math.sin(xd/2.0) + \ + a = math.sin(xd / 2.0) * math.sin(xd / 2.0) + \ math.cos(x0r) * math.cos(x1r) * \ math.sin(yd / 2.0) * math.sin(yd / 2.0) c = 2.0 * math.atan2(math.sqrt(a), math.sqrt(1.0 - a)) @@ -36,28 +35,27 @@ def haversine(x0, y0, x1, y1, units=DistanceUnit.METERS): # Equirectangular approximation for when performance is key. Better at smaller distances def equirectangularApprox(x0, y0, x1, y1): - R = 6371000.0 # Meters - x0r = x0 * (math.pi / 180.0) # To radians + R = 6371000.0 # Meters + x0r = x0 * (math.pi / 180.0) # To radians x1r = x1 * (math.pi / 180.0) y0r = y0 * (math.pi / 180.0) y1r = y1 * (math.pi / 180.0) x = (y1r - y0r) * math.cos((x0r + x1r) / 2.0) y = x1r - x0r - d = math.sqrt(x*x + y*y) * R + d = math.sqrt(x * x + y * y) * R return d - class BoundingBox(object): def __init__(self, north=None, south=None, west=None, east=None, asString=None): if asString is not None: bboxParts = asString.split(",") - self.west=float(bboxParts[0]) - self.south=float(bboxParts[1]) - self.east=float(bboxParts[2]) - self.north=float(bboxParts[3]) + self.west = float(bboxParts[0]) + self.south = float(bboxParts[1]) + self.east = float(bboxParts[2]) + self.north = float(bboxParts[3]) else: self.north = north self.south = south @@ -65,7 +63,7 @@ class BoundingBox(object): self.east = east def toString(self): - return "%s,%s,%s,%s"%(self.west, self.south, self.east, self.north) + return "%s,%s,%s,%s" % (self.west, self.south, self.east, self.north) def toMap(self): return { @@ -75,9 +73,12 @@ class BoundingBox(object): "ymax": self.north } + ''' Constrains, does not expand. ''' + + class BoundsConstrainer(BoundingBox): def __init__(self, north=None, south=None, west=None, east=None, asString=None): @@ -110,4 +111,4 @@ class BoundsConstrainer(BoundingBox): self.testEast(east) def testOtherConstrainer(self, other): - self.testCoords(north=other.north, south=other.south, west=other.west, east=other.east) \ No newline at end of file + self.testCoords(north=other.north, south=other.south, west=other.west, east=other.east) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/histogramplot.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/histogramplot.py b/analysis/webservice/algorithms/doms/histogramplot.py index a413769..23f1f01 100644 --- a/analysis/webservice/algorithms/doms/histogramplot.py +++ b/analysis/webservice/algorithms/doms/histogramplot.py @@ -1,19 +1,16 @@ - -import BaseDomsHandler -import ResultsStorage import string from cStringIO import StringIO -import matplotlib.mlab as mlab - from multiprocessing import Process, Manager -import numpy as np -import matplotlib.pyplot as plt import matplotlib -matplotlib.use('Agg') - +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt +import numpy as np +import BaseDomsHandler +import ResultsStorage +matplotlib.use('Agg') PARAMETER_TO_FIELD = { "sst": "sea_water_temperature", @@ -25,10 +22,13 @@ PARAMETER_TO_UNITS = { "sss": "(g/L)" } + class DomsHistogramPlotQueryResults(BaseDomsHandler.DomsQueryResults): - def __init__(self, x, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, computeOptions=None, executionId=None, plot=None): - BaseDomsHandler.DomsQueryResults.__init__(self, results=x, args=args, details=details, bounds=bounds, count=count, computeOptions=computeOptions, executionId=executionId) + def __init__(self, x, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, + computeOptions=None, executionId=None, plot=None): + BaseDomsHandler.DomsQueryResults.__init__(self, results=x, args=args, details=details, bounds=bounds, + count=count, computeOptions=computeOptions, executionId=executionId) self.__primary = primary self.__secondary = secondary self.__x = x @@ -40,15 +40,11 @@ class DomsHistogramPlotQueryResults(BaseDomsHandler.DomsQueryResults): def render(d, x, primary, secondary, parameter, norm_and_curve=False): - fig, ax = plt.subplots() fig.suptitle(string.upper("%s vs. %s" % (primary, secondary)), fontsize=14, fontweight='bold') - - n, bins, patches = plt.hist(x, 50, normed=norm_and_curve, facecolor='green', alpha=0.75) - if norm_and_curve: mean = np.mean(x) variance = np.var(x) @@ -83,7 +79,6 @@ def renderAsync(x, primary, secondary, parameter, norm_and_curve): def createHistogramPlot(id, parameter, norm_and_curve=False): - with ResultsStorage.ResultsRetrieval() as storage: params, stats, data = storage.retrieveResults(id) @@ -95,13 +90,12 @@ def createHistogramPlot(id, parameter, norm_and_curve=False): plot = renderAsync(x, primary, secondary, parameter, norm_and_curve) r = DomsHistogramPlotQueryResults(x=x, parameter=parameter, primary=primary, secondary=secondary, - args=params, details=stats, - bounds=None, count=None, computeOptions=None, executionId=id, plot=plot) + args=params, details=stats, + bounds=None, count=None, computeOptions=None, executionId=id, plot=plot) return r def createHistTable(results, secondary, parameter): - x = [] field = PARAMETER_TO_FIELD[parameter] if parameter in PARAMETER_TO_FIELD else PARAMETER_TO_FIELD["sst"] @@ -114,4 +108,4 @@ def createHistTable(results, secondary, parameter): b = match[field] x.append((a - b)) - return x \ No newline at end of file + return x http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/mapplot.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/mapplot.py b/analysis/webservice/algorithms/doms/mapplot.py index 47870a7..2c476da 100644 --- a/analysis/webservice/algorithms/doms/mapplot.py +++ b/analysis/webservice/algorithms/doms/mapplot.py @@ -1,19 +1,17 @@ +import string +from cStringIO import StringIO +from multiprocessing import Process, Manager +import matplotlib +import matplotlib.pyplot as plt +import numpy as np from mpl_toolkits.basemap import Basemap import BaseDomsHandler import ResultsStorage -import numpy as np -import string -from cStringIO import StringIO - -from multiprocessing import Process, Manager -import matplotlib.pyplot as plt -import matplotlib matplotlib.use('Agg') - PARAMETER_TO_FIELD = { "sst": "sea_water_temperature", "sss": "sea_water_salinity" @@ -42,7 +40,6 @@ def render(d, lats, lons, z, primary, secondary, parameter): fig = plt.figure() ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) - ax.set_title(string.upper("%s vs. %s" % (primary, secondary))) # ax.set_ylabel('Latitude') # ax.set_xlabel('Longitude') @@ -60,12 +57,10 @@ def render(d, lats, lons, z, primary, secondary, parameter): minLon, maxLon, minLat, maxLat = __square(minLon, maxLon, minLat, maxLat) - # m = Basemap(projection='mill', llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80,resolution='l') m = Basemap(projection='mill', llcrnrlon=minLon, llcrnrlat=minLat, urcrnrlon=maxLon, urcrnrlat=maxLat, resolution='l') - m.drawparallels(np.arange(minLat, maxLat, (maxLat - minLat) / 5.0), labels=[1, 0, 0, 0], fontsize=10) m.drawmeridians(np.arange(minLon, maxLon, (maxLon - minLon) / 5.0), labels=[0, 0, 0, 1], fontsize=10) @@ -73,12 +68,11 @@ def render(d, lats, lons, z, primary, secondary, parameter): m.drawmapboundary(fill_color='#99ffff') m.fillcontinents(color='#cc9966', lake_color='#99ffff') - #lats, lons = np.meshgrid(lats, lons) + # lats, lons = np.meshgrid(lats, lons) masked_array = np.ma.array(z, mask=np.isnan(z)) z = masked_array - values = np.zeros(len(z)) for i in range(0, len(z)): values[i] = ((z[i] - np.min(z)) / (np.max(z) - np.min(z)) * 20.0) + 10 @@ -87,7 +81,6 @@ def render(d, lats, lons, z, primary, secondary, parameter): im1 = m.scatter(x, y, values) - im1.set_array(z) cb = m.colorbar(im1) @@ -102,10 +95,12 @@ def render(d, lats, lons, z, primary, secondary, parameter): return plot - class DomsMapPlotQueryResults(BaseDomsHandler.DomsQueryResults): - def __init__(self, lats, lons, z, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, computeOptions=None, executionId=None, plot=None): - BaseDomsHandler.DomsQueryResults.__init__(self, results={"lats": lats, "lons": lons, "values": z}, args=args, details=details, bounds=bounds, count=count, computeOptions=computeOptions, executionId=executionId) + def __init__(self, lats, lons, z, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, + computeOptions=None, executionId=None, plot=None): + BaseDomsHandler.DomsQueryResults.__init__(self, results={"lats": lats, "lons": lons, "values": z}, args=args, + details=details, bounds=bounds, count=count, + computeOptions=computeOptions, executionId=executionId) self.__lats = lats self.__lons = lons self.__z = np.array(z) @@ -114,15 +109,10 @@ class DomsMapPlotQueryResults(BaseDomsHandler.DomsQueryResults): self.__secondary = secondary self.__plot = plot - - def toImage(self): return self.__plot - - - def renderAsync(x, y, z, primary, secondary, parameter): manager = Manager() d = manager.dict() @@ -132,9 +122,7 @@ def renderAsync(x, y, z, primary, secondary, parameter): return d['plot'] - def createMapPlot(id, parameter): - with ResultsStorage.ResultsRetrieval() as storage: params, stats, data = storage.retrieveResults(id) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/scatterplot.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/scatterplot.py b/analysis/webservice/algorithms/doms/scatterplot.py index 0cbe110..87eec68 100644 --- a/analysis/webservice/algorithms/doms/scatterplot.py +++ b/analysis/webservice/algorithms/doms/scatterplot.py @@ -1,17 +1,14 @@ - -import BaseDomsHandler -import ResultsStorage import string from cStringIO import StringIO - from multiprocessing import Process, Manager -import matplotlib.pyplot as plt import matplotlib -matplotlib.use('Agg') - +import matplotlib.pyplot as plt +import BaseDomsHandler +import ResultsStorage +matplotlib.use('Agg') PARAMETER_TO_FIELD = { "sst": "sea_water_temperature", @@ -24,7 +21,6 @@ PARAMETER_TO_UNITS = { } - def render(d, x, y, z, primary, secondary, parameter): fig, ax = plt.subplots() @@ -41,10 +37,13 @@ def render(d, x, y, z, primary, secondary, parameter): plt.savefig(sio, format='png') d['plot'] = sio.getvalue() + class DomsScatterPlotQueryResults(BaseDomsHandler.DomsQueryResults): - def __init__(self, x, y, z, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, computeOptions=None, executionId=None, plot=None): - BaseDomsHandler.DomsQueryResults.__init__(self, results=[x, y], args=args, details=details, bounds=bounds, count=count, computeOptions=computeOptions, executionId=executionId) + def __init__(self, x, y, z, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, + computeOptions=None, executionId=None, plot=None): + BaseDomsHandler.DomsQueryResults.__init__(self, results=[x, y], args=args, details=details, bounds=bounds, + count=count, computeOptions=computeOptions, executionId=executionId) self.__primary = primary self.__secondary = secondary self.__x = x @@ -57,8 +56,6 @@ class DomsScatterPlotQueryResults(BaseDomsHandler.DomsQueryResults): return self.__plot - - def renderAsync(x, y, z, primary, secondary, parameter): manager = Manager() d = manager.dict() @@ -68,9 +65,7 @@ def renderAsync(x, y, z, primary, secondary, parameter): return d['plot'] - def createScatterPlot(id, parameter): - with ResultsStorage.ResultsRetrieval() as storage: params, stats, data = storage.retrieveResults(id) @@ -105,8 +100,3 @@ def createScatterTable(results, secondary, parameter): z.append(a - b) return x, y, z - - - - - http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms/doms/workerthread.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms/doms/workerthread.py b/analysis/webservice/algorithms/doms/workerthread.py index 097e604..eed003d 100644 --- a/analysis/webservice/algorithms/doms/workerthread.py +++ b/analysis/webservice/algorithms/doms/workerthread.py @@ -1,7 +1,6 @@ -import os -import sys import threading + class WorkerThread(threading.Thread): def __init__(self, method, params): @@ -11,24 +10,20 @@ class WorkerThread(threading.Thread): self.completed = False self.results = None - def run(self): - - self.results = self.method(*self.params) self.completed = True def __areAllComplete(threads): - for thread in threads: if not thread.completed: return False return True -def wait(threads, startFirst=False, poll=0.5): +def wait(threads, startFirst=False, poll=0.5): if startFirst: for thread in threads: thread.start() @@ -37,11 +32,11 @@ def wait(threads, startFirst=False, poll=0.5): threading._sleep(poll) - def foo(param1, param2): print param1, param2 return "c" + if __name__ == "__main__": thread = WorkerThread(foo, params=("a", "b")) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms_spark/HofMoellerSpark.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms_spark/HofMoellerSpark.py b/analysis/webservice/algorithms_spark/HofMoellerSpark.py index f6a0118..46d6931 100644 --- a/analysis/webservice/algorithms_spark/HofMoellerSpark.py +++ b/analysis/webservice/algorithms_spark/HofMoellerSpark.py @@ -7,14 +7,13 @@ import logging import traceback from cStringIO import StringIO from datetime import datetime -from multiprocessing.dummy import Pool, Manager import matplotlib.pyplot as plt import mpld3 import numpy as np -from nexustiles.nexustiles import NexusTileService from matplotlib import cm from matplotlib.ticker import FuncFormatter +from nexustiles.nexustiles import NexusTileService from webservice.NexusHandler import SparkHandler, nexus_handler, DEFAULT_PARAMETERS_SPEC from webservice.webmodel import NexusProcessingException, NexusResults @@ -129,6 +128,7 @@ class BaseHoffMoellerHandlerImpl(SparkHandler): results = self.applyDeseasonToHofMoellerByField(results, pivot, field="max", append=append) return results + def determine_parllelism(num_tiles): """ Try to stay at a maximum of 1500 tiles per partition; But don't go over 128 partitions. @@ -137,6 +137,7 @@ def determine_parllelism(num_tiles): num_partitions = max(min(num_tiles // 1500, 128), 8) return num_partitions + @nexus_handler class LatitudeTimeHoffMoellerSparkHandlerImpl(BaseHoffMoellerHandlerImpl): name = "Latitude/Time HofMoeller Spark" @@ -149,11 +150,13 @@ class LatitudeTimeHoffMoellerSparkHandlerImpl(BaseHoffMoellerHandlerImpl): BaseHoffMoellerHandlerImpl.__init__(self) def calc(self, computeOptions, **args): - nexus_tiles_spark = [(tile.tile_id, x, computeOptions.get_min_lat(), computeOptions.get_max_lat(), computeOptions.get_min_lon(), computeOptions.get_max_lon()) for x, tile in enumerate(self._tile_service.find_tiles_in_box(computeOptions.get_min_lat(), computeOptions.get_max_lat(), - computeOptions.get_min_lon(), computeOptions.get_max_lon(), - computeOptions.get_dataset()[0], - computeOptions.get_start_time(), - computeOptions.get_end_time(), fetch_data=False))] + nexus_tiles_spark = [(tile.tile_id, x, computeOptions.get_min_lat(), computeOptions.get_max_lat(), + computeOptions.get_min_lon(), computeOptions.get_max_lon()) for x, tile in enumerate( + self._tile_service.find_tiles_in_box(computeOptions.get_min_lat(), computeOptions.get_max_lat(), + computeOptions.get_min_lon(), computeOptions.get_max_lon(), + computeOptions.get_dataset()[0], + computeOptions.get_start_time(), + computeOptions.get_end_time(), fetch_data=False))] if len(nexus_tiles_spark) == 0: raise NexusProcessingException.NoDataException(reason="No data found for selected timeframe") @@ -183,11 +186,13 @@ class LongitudeTimeHoffMoellerSparkHandlerImpl(BaseHoffMoellerHandlerImpl): BaseHoffMoellerHandlerImpl.__init__(self) def calc(self, computeOptions, **args): - nexus_tiles_spark = [(tile.tile_id, x, computeOptions.get_min_lat(), computeOptions.get_max_lat(), computeOptions.get_min_lon(), computeOptions.get_max_lon()) for x, tile in enumerate(self._tile_service.find_tiles_in_box(computeOptions.get_min_lat(), computeOptions.get_max_lat(), - computeOptions.get_min_lon(), computeOptions.get_max_lon(), - computeOptions.get_dataset()[0], - computeOptions.get_start_time(), - computeOptions.get_end_time(), fetch_data=False))] + nexus_tiles_spark = [(tile.tile_id, x, computeOptions.get_min_lat(), computeOptions.get_max_lat(), + computeOptions.get_min_lon(), computeOptions.get_max_lon()) for x, tile in enumerate( + self._tile_service.find_tiles_in_box(computeOptions.get_min_lat(), computeOptions.get_max_lat(), + computeOptions.get_min_lon(), computeOptions.get_max_lon(), + computeOptions.get_dataset()[0], + computeOptions.get_start_time(), + computeOptions.get_end_time(), fetch_data=False))] if len(nexus_tiles_spark) == 0: raise NexusProcessingException.NoDataException(reason="No data found for selected timeframe") http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms_spark/Matchup.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms_spark/Matchup.py b/analysis/webservice/algorithms_spark/Matchup.py index 8d90389..ef8289f 100644 --- a/analysis/webservice/algorithms_spark/Matchup.py +++ b/analysis/webservice/algorithms_spark/Matchup.py @@ -6,7 +6,6 @@ California Institute of Technology. All rights reserved import json import logging import threading -import time from datetime import datetime from itertools import chain from math import cos, radians http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms_spark/TimeSeriesSpark.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py index 6b2c6a1..0a46473 100644 --- a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py +++ b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py @@ -187,7 +187,8 @@ class TimeSeriesHandlerImpl(SparkHandler): the_time = datetime.now() results, meta = spark_driver(daysinrange, bounding_polygon, shortName, spark_nparts_needed=spark_nparts_needed, sc=self._sc) - self.log.info("Time series calculation took %s for dataset %s" % (str(datetime.now() - the_time), shortName)) + self.log.info( + "Time series calculation took %s for dataset %s" % (str(datetime.now() - the_time), shortName)) if apply_seasonal_cycle_filter: the_time = datetime.now() http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/algorithms_spark/__init__.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/algorithms_spark/__init__.py b/analysis/webservice/algorithms_spark/__init__.py index 51727dc..3b07116 100644 --- a/analysis/webservice/algorithms_spark/__init__.py +++ b/analysis/webservice/algorithms_spark/__init__.py @@ -2,8 +2,8 @@ Copyright (c) 2016 Jet Propulsion Laboratory, California Institute of Technology. All rights reserved """ -import os import logging +import os log = logging.getLogger(__name__) http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/matserver.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/matserver.py b/analysis/webservice/matserver.py index 5cdd8a2..43b7e43 100644 --- a/analysis/webservice/matserver.py +++ b/analysis/webservice/matserver.py @@ -3,9 +3,8 @@ Copyright (c) 2016 Jet Propulsion Laboratory, California Institute of Technology. All rights reserved """ import matplotlib.pyplot as plt -import numpy as np - import mpld3 +import numpy as np from mpld3 import plugins fig, ax = plt.subplots() http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/webapp.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/webapp.py b/analysis/webservice/webapp.py index 121624a..7382734 100644 --- a/analysis/webservice/webapp.py +++ b/analysis/webservice/webapp.py @@ -6,7 +6,7 @@ import ConfigParser import importlib import json import logging -import sys, os +import sys import traceback from multiprocessing.pool import ThreadPool http://git-wip-us.apache.org/repos/asf/incubator-sdap-nexus/blob/f73d912e/analysis/webservice/webmodel.py ---------------------------------------------------------------------- diff --git a/analysis/webservice/webmodel.py b/analysis/webservice/webmodel.py index 70621af..fb2e55a 100644 --- a/analysis/webservice/webmodel.py +++ b/analysis/webservice/webmodel.py @@ -2,19 +2,21 @@ Copyright (c) 2016 Jet Propulsion Laboratory, California Institute of Technology. All rights reserved """ -import re +import hashlib +import inspect import json -import numpy as np -from shapely.geometry import Polygon +import re +import time from datetime import datetime from decimal import Decimal -import time -import inspect -import hashlib + +import numpy as np from pytz import UTC, timezone +from shapely.geometry import Polygon EPOCH = timezone('UTC').localize(datetime(1970, 1, 1)) + class RequestParameters(object): SEASONAL_CYCLE_FILTER = "seasonalFilter" MAX_LAT = "maxLat" @@ -38,6 +40,7 @@ class RequestParameters(object): PLOT_TYPE = "plotType" SPARK_CFG = "spark" + class StandardNexusErrors: UNKNOWN = 1000 NO_DATA = 1001 @@ -67,6 +70,7 @@ class SparkConfig(object): MAX_NUM_PARTS = 8192 DEFAULT = "local,1,1" + class StatsComputeOptions(object): def __init__(self): pass @@ -131,7 +135,7 @@ class StatsComputeOptions(object): def get_plot_type(self, default="default"): raise Exception("Please implement") - def get_spark_cfg (self, default=SparkConfig.DEFAULT): + def get_spark_cfg(self, default=SparkConfig.DEFAULT): raise Exception("Please implement") @@ -284,7 +288,7 @@ class NexusRequestObject(StatsComputeOptions): try: dt = datetime.strptime(time_str, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=UTC) except ValueError: - dt = datetime.utcfromtimestamp(int(time_str)/1000).replace(tzinfo=UTC) + dt = datetime.utcfromtimestamp(int(time_str) / 1000).replace(tzinfo=UTC) return dt def get_end_datetime_ms(self): @@ -292,7 +296,7 @@ class NexusRequestObject(StatsComputeOptions): try: dt = datetime.strptime(time_str, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=UTC) except ValueError: - dt = datetime.utcfromtimestamp(int(time_str)/1000).replace(tzinfo=UTC) + dt = datetime.utcfromtimestamp(int(time_str) / 1000).replace(tzinfo=UTC) return dt def get_start_row(self): @@ -325,20 +329,23 @@ class NexusRequestObject(StatsComputeOptions): def get_spark_cfg(self, default=SparkConfig.DEFAULT): arg = self.get_argument(RequestParameters.SPARK_CFG, default) try: - master,nexecs,nparts = arg.split(',') + master, nexecs, nparts = arg.split(',') except: raise ValueError('Invalid spark configuration: %s' % arg) if master not in ("local", "yarn", "mesos"): raise ValueError('Invalid spark master: %s' % master) nexecs = int(nexecs) if (nexecs < 1) or (nexecs > SparkConfig.MAX_NUM_EXECS): - raise ValueError('Invalid number of Spark executors: %d (must be between 1 and %d)' % (nexecs, SparkConfig.MAX_NUM_EXECS)) + raise ValueError('Invalid number of Spark executors: %d (must be between 1 and %d)' % ( + nexecs, SparkConfig.MAX_NUM_EXECS)) nparts = int(nparts) if (nparts < 1) or (nparts > SparkConfig.MAX_NUM_PARTS): - raise ValueError('Invalid number of Spark data partitions: %d (must be between 1 and %d)' % (nparts,SparkConfig.MAX_NUM_PARTS)) + raise ValueError('Invalid number of Spark data partitions: %d (must be between 1 and %d)' % ( + nparts, SparkConfig.MAX_NUM_PARTS)) if master == "local": master = "local[%d]" % nexecs - return master,nexecs,nparts + return master, nexecs, nparts + class NexusResults: def __init__(self, results=None, meta=None, stats=None, computeOptions=None, status_code=200, **args): @@ -480,8 +487,8 @@ class CustomEncoder(json.JSONEncoder): __CACHE = {} -def cached(ttl=60000): +def cached(ttl=60000): def _hash_function_signature(func): hash_object = hashlib.md5(str(inspect.getargspec(func)) + str(func)) return hash_object.hexdigest() @@ -509,11 +516,7 @@ def cached(ttl=60000): } return __CACHE[hash]["result"] + return func_wrapper return _cached_decorator - - - - -
