Delete src package Project: http://git-wip-us.apache.org/repos/asf/incubator-cmda/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cmda/commit/011075b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cmda/tree/011075b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cmda/diff/011075b9
Branch: refs/heads/master Commit: 011075b9d0093f6ecadc2b675a9851a3b522b708 Parents: 6a15e2c Author: mingqi830 <m...@andrew.cmu.edu> Authored: Wed Sep 2 14:59:51 2015 -0700 Committer: mingqi830 <m...@andrew.cmu.edu> Committed: Wed Sep 2 14:59:51 2015 -0700 ---------------------------------------------------------------------- public/src/conditionalSampling2Var/__init__.py | 0 public/src/conditionalSampling2Var/__init__.pyc | Bin 164 -> 0 bytes .../conditionalSampling2Var/binBoundarySpec.m | 19 - .../call_conditionalSampling2Var.py | 119 --- .../call_conditionalSampling2Var.pyc | Bin 4199 -> 0 bytes .../displayConditionalSampling2Var.m | 301 ------ ...rtedBy_ncar_cam5_hus_and_ncc_noresm_hus.jpeg | Bin 118196 -> 0 bytes ...ortedBy_gfdl_esm2g_pr_and_gfdl_esm2g_pr.jpeg | Bin 93009 -> 0 bytes .../src/conditionalSampling2Var/octaveWrapper | 112 --- public/src/conditionalSampling2Var/testScript | 12 - public/src/correlationMap/__init__.py | 0 public/src/correlationMap/__init__.pyc | Bin 155 -> 0 bytes .../src/correlationMap/call_correlationMap.py | 128 --- .../src/correlationMap/call_correlationMap.pyc | Bin 3470 -> 0 bytes public/src/correlationMap/pythonWrapper | 909 ------------------- public/src/correlationMap/wrapper | 4 - public/src/regridAndDownload/__init__.py | 0 public/src/regridAndDownload/__init__.pyc | Bin 158 -> 0 bytes .../regridAndDownload/call_regridAndDownload.py | 99 -- .../call_regridAndDownload.pyc | Bin 3297 -> 0 bytes public/src/regridAndDownload/octaveWrapper | 106 --- .../src/regridAndDownload/regridAndDownload.m | 28 - public/src/regridAndDownload/testScript | 7 - 23 files changed, 1844 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/__init__.py ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/__init__.py b/public/src/conditionalSampling2Var/__init__.py deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/__init__.pyc ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/__init__.pyc b/public/src/conditionalSampling2Var/__init__.pyc deleted file mode 100644 index 48fce15..0000000 Binary files a/public/src/conditionalSampling2Var/__init__.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/binBoundarySpec.m ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/binBoundarySpec.m b/public/src/conditionalSampling2Var/binBoundarySpec.m deleted file mode 100644 index a4173ee..0000000 --- a/public/src/conditionalSampling2Var/binBoundarySpec.m +++ /dev/null @@ -1,19 +0,0 @@ -function binB = binBoundarySpec(binB) -% -% This function generates a set of bin boundary values -% -% -% Assuming the last element specifying the number of nBins -nBin = length(binB); - -if nBin > 3 && nBin == binB(end) + 2 - binB = binB(1:(nBin-1)); -elseif nBin == 3 - if binB(3) <= 0 - binB = []; - else - binB = linspace(binB(1), binB(2), binB(3)+1); - end -else - error('*** Inconsistent data for bin boundary value specification!!!'); -end http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/call_conditionalSampling2Var.py ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/call_conditionalSampling2Var.py b/public/src/conditionalSampling2Var/call_conditionalSampling2Var.py deleted file mode 100644 index 7688d96..0000000 --- a/public/src/conditionalSampling2Var/call_conditionalSampling2Var.py +++ /dev/null @@ -1,119 +0,0 @@ -# call_threeDimZonalMean2Var.py -import string -import subprocess -import os -from os.path import basename - -if __name__ == '__main__': - import sys - sys.path.append('../time_bounds') - from getTimeBounds import correctTimeBounds2 -else: - from svc.src.time_bounds.getTimeBounds import correctTimeBounds2 - -class call_conditionalSampling2Var: - def __init__(self, data_source, var, start_time, end_time, lon1, lon2, lat1, lat2, pres1, pres2, months, - env_var_source1, env_var1, bin_min1, bin_max1, bin_n1, env_var_plev1, - env_var_source2, env_var2, bin_min2, bin_max2, bin_n2, env_var_plev2, output_dir, displayOpt): - self.data_source = data_source # for e.g. "NCAR_cam5" or "nasa_airs", etc - self.var = var # CMIP5 variable names, e.g. 'ta', 'hus', 'clt' - self.lon1 = lon1 # longitude range, min, units = deg - self.lon2 = lon2 # longitude range, max, units = deg - self.lat1 = lat1 # latitude range, min, units = deg - self.lat2 = lat2 # latitude range, max, units = deg - self.pres1 = pres1 # pressure level 1 for pressure range - self.pres2 = pres2 # pressure level 2 for pressure range - self.months = months # month index to specify season, e.g. 6,7,8 for boreal summer - self.env_var_source1 = env_var_source1 # first large scale environmental variable data source, e.g. "NCAR_cam5" - self.env_var1 = env_var1 # first large scale environmental variable CMIP5 name, e.g. 'ts', 'tos' - self.bin_min1 = bin_min1 # min value of bin boundary for sorting first large scale env var - self.bin_max1 = bin_max1 # max value of bin boundary for sorting first large scale env var - self.bin_n1 = bin_n1 # number of bins to be used for the first large scale variable - self.env_var_plev1 = env_var_plev1 # pressure level for env var if it is 3-d - self.env_var_source2 = env_var_source2 # first large scale environmental variable data source, e.g. "NCAR_cam5" - self.env_var2 = env_var2 # first large scale environmental variable CMIP5 name, e.g. 'ts', 'tos' - self.bin_min2 = bin_min2 # min value of bin boundary for sorting first large scale env var - self.bin_max2 = bin_max2 # max value of bin boundary for sorting first large scale env var - self.bin_n2 = bin_n2 # number of bins to be used for the first large scale variable - self.env_var_plev2 = env_var_plev2 # pressure level for env var if it is 3-d - self.output_dir = output_dir # output directory for figure and data file - self.displayOpt = displayOpt # display option, if in binary, the last 3 bits = [z y x] - availableTimeBnds1 = correctTimeBounds2('2', data_source.replace("_", "/"), var, env_var_source1.replace("_", "/"), env_var1, start_time, end_time) - availableTimeBnds2 = correctTimeBounds2('2', data_source.replace("_", "/"), var, env_var_source2.replace("_", "/"), env_var2, start_time, end_time) - self.start_time = str(max(int(availableTimeBnds1[0]), int(availableTimeBnds2[0]))); - self.end_time = str(min(int(availableTimeBnds1[1]), int(availableTimeBnds2[1]))); - # z = map scale, y = vertical axis, x = horizontal axis - # 1 = log, 0 = lin - - def displayConditionalSampling2Var(self): - - inputs = self.data_source + ' ' + self.var + ' ' + self.start_time + ' ' + self.end_time + ' ' + \ - self.lon1 + ',' + self.lon2 + ' ' + self.lat1 + ',' + self.lat2 + ' ' + \ - self.pres1 + ',' + self.pres2 + ' ' + self.months + ' ' + \ - self.env_var_source1 + ' ' + self.env_var1 + ' ' + \ - self.bin_min1 + ',' + self.bin_max1 + ',' + self.bin_n1 + ' ' + self.env_var_plev1 + ' ' + \ - self.env_var_source2 + ' ' + self.env_var2 + ' ' + \ - self.bin_min2 + ',' + self.bin_max2 + ',' + self.bin_n2 + ' ' + self.env_var_plev2 + ' ' + self.output_dir + ' ' + self.displayOpt - print 'inputs: ', inputs - command = './octaveWrapper ' + inputs - cmd = command.split(' ') - cmdstring = string.join(cmd, ' ') - print 'cmdstring: ', cmdstring - - if self.start_time == '0' or self.end_time == '0': - return ('No Data', '', '') - - try: - proc=subprocess.Popen(cmd, cwd='.', stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) - # wait for the process to finish - stdout_value, stderr_value = proc.communicate() - print 'stdout_value: ', stdout_value - print 'stderr_value: ', stderr_value - - if stderr_value.find('error:') >= 0: - return (stderr_value, '', '') - - fst = 'figFile: ' - l1 = len(fst) - ### print 'l1: ', l1 - image_filename = '' - - fst2 = 'dataFile: ' - l2 = len(fst2) - ### print 'l2: ', l2 - data_filename = '' - - lines = stdout_value.split('\n') - for line in lines: - ### print '*****: ', line - if line.find('figFile: ') >= 0: - print '***** line: ', line - image_filename = line[l1:] - - if line.find('dataFile: ') >= 0: - print '***** line: ', line - data_filename = line[l2:] - - print 'image_filename: ', image_filename - print 'data_filename: ', data_filename - return (stdout_value, image_filename, data_filename) - except OSError, e: - err_mesg = 'The subprocess "%s" returns with an error: %s.' % (cmdstring, e) - return (err_mesg, '', '') - - -if __name__ == '__main__': - #./octaveWrapper giss_e2-r clw 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'giss_e2-r' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' - # c1 = call_conditionalSampling('cccma_canesm2', 'ts', '200101', '200212', '0', '360', '-90', '90', '', '', '5,6,7,8', 'cccma_canesm2', 'tos', '294','305','20', '', './', '0') - ### c1 = call_conditionalSampling('giss_e2-r', 'clw', '200101', '200212', '0', '360', '-30', '30', '20000', '90000', '5,6,7,8', 'giss_e2-r', 'tos', '294','305','20', '-1', './', '6') - - c1 = call_conditionalSampling2Var('ncc_noresm', 'cli', '200001', '200202', '0', '360', '-60', '60', '20000', '25000', '3,4,5', 'ncc_noresm', 'tos', '290','303','13', '-999999', 'ncc_noresm', 'wap', '-0.06', '0.06', '6', '50000', './', '0') - - mesg = c1.displayConditionalSampling2Var() - print 'mesg: ', mesg - - -### ./octaveWrapper giss_e2-r cli 200001 200202 0,360 -30,30 20000,90000 3,4,5 giss_e2-r ta 294,305,20 200 /home/svc/cmac/trunk/services/svc/svc/static/conditionalSampling/70ba451132c303980b8195252cf26364 3 -### causes division by zero and index out of bounds errors - - http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/call_conditionalSampling2Var.pyc ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/call_conditionalSampling2Var.pyc b/public/src/conditionalSampling2Var/call_conditionalSampling2Var.pyc deleted file mode 100644 index 5a85e30..0000000 Binary files a/public/src/conditionalSampling2Var/call_conditionalSampling2Var.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/displayConditionalSampling2Var.m ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/displayConditionalSampling2Var.m b/public/src/conditionalSampling2Var/displayConditionalSampling2Var.m deleted file mode 100644 index cb312ed..0000000 --- a/public/src/conditionalSampling2Var/displayConditionalSampling2Var.m +++ /dev/null @@ -1,301 +0,0 @@ -function status = displayConditionalSampling2Var (dataFile, varName, startTime, stopTime, lonRange, latRange, monthIdx, plevRange, largeScaleDataFile1, largeScaleVarName1, largeScaleValueBinB1, largeScalePlev1, largeScaleDataFile2, largeScaleVarName2, largeScaleValueBinB2, largeScalePlev2, outputFile, figFile, displayOpt) -% -% This function extracts relevant data from the data file list according -% the specified temporal range [startTime, stopTime] -% -% Input: -% dataFile -- a list of relevant data files -% figFile -- the name of the output file for storing the figure to be displayed -% varName -- the physical variable of interest, or to be displayed, CMIP5 variable name used in netcdf file -% startTime -- the start time of the temporal window over which the climatology is computed, string 'yyyymm' -% stopTime -- the stop time of the temporal window over which the climatology is computed, string 'yyyymm' -% lonRnage -- longitude boundary specification, expect [min, max] (deg) -% latRnage -- latitude boundary specification, expect [min, max] (deg) -% monthIdx -- specify months within a year, which is useful for computing climatology for a specific season. -% plevRange -- presssure level range in units of (Pa) -% largeScaleDataFile -- a list of relevant large scale data files -% largeScaleVarName -- CMIP5 name for the large scale variable -% largeScaleValueBinB -- bin boundary specification, either as a vector of bin boundaries or [min,max,nBin] -% largeScalePlev -- pressure level for the large scale variable, e.g. vertical velocity at 50000Pa -% outputFile -- a data file for storing plotting data in netcdf format -% displayOpt -- flags to specify display scale, linear vs logarithmic, 3-bits, in the order (z,y,x), 0=lin, 1=log, -% -% Output: -% status -- a status flag, 0 = okay, -1 something is not right -% -% Author: Chengxing Zhai -% -% Revision history: -% 2013/09/30: Initial version, cz -% -status = -1; - -if nargin < 19 - displayOpt = 0; -end - -% Need to read out first the data to be sorted -nMonths = numberOfMonths(startTime, stopTime); -monthList = monthListWithin(startTime, stopTime, monthIdx); - -printf('number of month = %d\n', nMonths); - -monthlyData = []; - -% Let us first assume the same grid -% We now sort the large scale variable aaccording to the bin -% sorted data mean and stddev for each bin -v_sorted_m = []; -v2_sorted_m = []; -v_sorted_std = []; - -dataIsTwoDim = false; - -nFiles = length(dataFile); -printf('number of files = %d\n', nFiles); -v = []; -lon = []; -lat = []; - -file_start_time = {}; -file_stop_time = {}; - -for fileI = 1:nFiles - thisFile = dataFile{fileI}; - - if isempty(v_sorted_m) - lon = ncread(thisFile, 'lon'); - lat = ncread(thisFile, 'lat'); - - [lon, lat, lonIdx, latIdx] = subIdxLonAndLat(lon, lat, lonRange, latRange); - nLon = length(lon); - nLat = length(lat); - - largeScaleVarData = cell(2,1); - - % This loads the large scale variabe data - largeScaleVarData{1} = readAndRegridTwoDimData(largeScaleDataFile1, largeScaleVarName1, startTime, stopTime, lon, lat, largeScalePlev1); - largeScaleVarData{2} = readAndRegridTwoDimData(largeScaleDataFile2, largeScaleVarName2, startTime, stopTime, lon, lat, largeScalePlev2); - - nBinB = [length(largeScaleValueBinB1), length(largeScaleValueBinB2)]; - largeScaleValueBinB = {largeScaleValueBinB1, largeScaleValueBinB2}; - for ii = 1:2 - if nBinB(ii) <= 0 - largeScaleValueBinB{ii} = generateBinB(largeScaleVarData{ii}.data(:), 20); - elseif nBinB(ii) == 1 - largeScaleValueBinB{ii} = generateBinB(largeScaleVarData{ii}.data(:), largeScaleValueBinB{1}); - elseif nBinB(ii) == 2 - largeScaleValueBinB{ii} = linspace(largeScaleValueBinB{ii}(1), largeScaleValueBin{ii}(2), 10 + 1); - elseif nBinB(ii) == 3 - if largeScaleValueBin{ii}(3) <= 0 - largeScaleValueBinB{ii} = generateBinB(largeScaleVarData{ii}.data(:), 20); - else - largeScaleValueBinB{ii} = linspace(largeScaleValueBinB{ii}(1), largeScaleValueBin{ii}(2), largeScaleValueBin{ii}(3) + 1); - end - end - nBinB(ii) = length(largeScaleValueBinB{ii}); - end - nBins = nBinB - 1; - - n_sorted = zeros(nBins); - - [idxArrayForEachBin, binCenterValues, nSamples] = generateIdxForBins2(largeScaleValueBinB, largeScaleVarData); - - if isempty(plevRange) - dataIsTwoDim = true; - nP = 1; - elseif max(plevRange) <= 0 - dataIsTwoDim = true; - nP = 1; - else - dataIsTwoDim = false; - plev = readPressureLevels(thisFile, 'plev'); - if length(plevRange) == 1 - [mV, mIdx] = min(abs(plevRange - plev)); - else - mIdx = find(plev >= min(plevRange) & plev <= max(plevRange)); - end - plev = plev(mIdx); - nP = length(plev); - end - - long_name = ncreadatt(thisFile, varName, 'long_name'); - - v_sorted_m = zeros(nBins, 'single'); - v2_sorted_m = zeros(nBins, 'single'); - v_sorted_std = zeros(nBins, 'single'); - n_sorted_valid = zeros(nBins, 'single'); - end - - v = ncreadVar(thisFile, varName); - - v_units = ncreadatt(thisFile, varName, 'units'); - - [startTime_thisFile, stopTime_thisFile] = parseDateInFileName(dataFile{fileI}); - - file_start_time{fileI} = startTime_thisFile; - file_stop_time{fileI} = stopTime_thisFile; - - monthIdx1 = numberOfMonths(startTime, startTime_thisFile); - monthIdx2 = numberOfMonths(startTime, stopTime_thisFile); - - if dataIsTwoDim - nMonths_thisFile = size(v,3); - else - nMonths_thisFile = size(v,4); - end - - idx2Data_start = 1; - idx2Data_stop = nMonths_thisFile; - - if monthIdx1 <= 1 - idx2Data_start = 1 + (1 - monthIdx1); - monthIdx1 = 1; - end - - if monthIdx2 >= nMonths - idx2Data_stop = idx2Data_stop - (monthIdx2 - nMonths); - monthIdx2 = nMonths; - end - monthListThisFile = find(monthList >= monthIdx1 & monthList <= monthIdx2); - nMonthInThisFile = length(monthListThisFile); - - timeIdx = idx2Data_start:idx2Data_stop; - for monthI = 1:nMonthInThisFile - thisMonth = monthListThisFile(monthI); - if dataIsTwoDim - thisTwoDimSlice = v(lonIdx, latIdx, timeIdx(monthI)); - else - thisTwoDimSlice = meanExcludeNaN(v(lonIdx, latIdx, mIdx, timeIdx(monthI)), 3); % average over relevant levels - end - for binI1 = 1:nBins(1) - for binI2 = 1:nBins(2) - idx_thisBin = idxArrayForEachBin{binI1, binI2}; - idx_in_thisFile = mod(idx_thisBin(find(idx_thisBin > (thisMonth-1)*nLat*nLon & idx_thisBin <= thisMonth*nLat*nLon))-1, nLat*nLon) + 1; - - dataInThisBin = thisTwoDimSlice(idx_in_thisFile); - dataValidIdx = find(isfinite(dataInThisBin)); - n_sorted_valid(binI1,binI2) = n_sorted_valid(binI1,binI2) + length(dataValidIdx); - v_sorted_m(binI1, binI2) = v_sorted_m(binI1, binI2) + sum(dataInThisBin(dataValidIdx)); - v2_sorted_m(binI1, binI2) = v2_sorted_m(binI1, binI2) + sum(dataInThisBin(dataValidIdx).^2); - end - end - end - clear v; -end - -v_sorted_m = v_sorted_m ./ n_sorted_valid; -v2_sorted_m = v2_sorted_m ./ n_sorted_valid; -v_sorted_std = sqrt((v2_sorted_m - v_sorted_m.^2) ./ (n_sorted_valid - 1)); - -% We now determine the relevant time range used for this climatology calculation -[real_startTime, real_stopTime] = findRealTimeRange(file_start_time, file_stop_time, startTime, stopTime); - -[x_opt, y_opt, z_opt] = decodeDisplayOpt(displayOpt); -titleStr = [long_name ', sorted by ' largeScaleVarData{1}.name ' and ' largeScaleVarData{2}.name ', ' date2Str(startTime, '/') '-' date2Str(stopTime, '/')]; - -for ii = 1:2 -if isfield(largeScaleVarData{ii}, 'plev') - labelStr{ii} = [largeScaleVarData{ii}.name ' at ' num2str(round(mean(largeScaleVarData{ii}.plev)/100)) 'hPa (' largeScaleVarData{ii}.units ')' ] -else - labelStr{ii} = [largeScaleVarData{ii}.name '(' largeScaleVarData{ii}.units ')' ]; -end -end - -figure; - -if z_opt - z = log10(v_sorted_m' + 1e-4*(max(v_sorted_m(:)))); % to have dynamic range of 10^4 -else - z = v_sorted_m'; -end - -if y_opt - y = log10(binCenterValues{2}); -else - y = binCenterValues{2}; -end - -if x_opt - x = log10(binCenterValues{1}); -else - x = binCenterValues{1}; -end - -[z_valid, y_valid, x_valid] = subsetValidData(z, y, x); - -gFilter = gaussianFilter(3, 1); - -badDataFrac = sum(sum(~isfinite(z_valid)))/length(z_valid(:)); -if badDataFrac > 0.2 - imagesc(x_valid, -y_valid, z_valid); - hold on; - [c2, h2] = contour(interpGrid(x_valid, 2), interpGrid(-y_valid,2), filter2(gFilter, interp2(n_sorted_valid,2)')); - caxis([min(z_valid(:)), max(z_valid(:))]); - set(gca, 'yticklabel', num2str(-get(gca, 'ytick')')); -else - if badDataFrac < 0.02 - if badDataFrac < 0.005 - gFilter = gaussianFilter(5, 1.5); - end - contourf(interpGrid(x_valid, 2), interpGrid(y_valid,2), filter2(gFilter, interp2(z_valid, 2)), 15, 'linecolor', 'none'); - else - contourf(interpGrid(x_valid, 2), interpGrid(y_valid,2), interp2(z_valid, 2), 15, 'linecolor', 'none'); - end - hold on; - [c2, h2] = contour(interpGrid(x_valid, 2), interpGrid(y_valid,2), filter2(gFilter, interp2(n_sorted_valid,2)')); -end -set(h2, 'linecolor', [1, 0.0, 0.2], 'linewidth', 1); -set(h2, 'levellistmode', 'manual'); -l_list = round(get(h2, 'levellist')/10)*10; -set(h2, 'levellistmode', 'manual'); -set(h2, 'levellist', l_list); -clabel(c2, h2, l_list(1:2:end), 'fontsize', 12, 'fontweight', 'bold', 'color', [0, 0, 0], 'rotation', 0); -set(h2,'ShowText','on','TextStep',get(h2,'LevelStep')*2) - -if ~isempty(find(isnan(v_sorted_m(:)))) - cmap = colormap(); - cmap(1,:) = [1,1,1]; - colormap(cmap); -end -grid on; -set(gca, 'fontweight', 'bold'); -if y_opt - set(gca, 'yticklabel', num2str(10.^(currYTick))); -end -ylabel(labelStr{2}); -if x_opt - currXTick = get(gca, 'xtick')'; - set(gca, 'xticklabel', num2str(10.^(currXTick))); % -end -xlabel(labelStr{1}); - -cb = colorbar('southoutside'); -if z_opt - set(cb, 'xticklabel', num2str(10.^(get(cb, 'xtick')'),3)); -end -set(get(cb,'xlabel'), 'string', [long_name '(' v_units ')'], 'FontSize', 16); - -title(titleStr, 'fontsize', 13, 'fontweight', 'bold'); -print(gcf, figFile, '-djpeg'); -% adding title for color bar - -if strcmp(largeScaleVarName1, largeScaleVarName2) - data.dimNames = {[largeScaleVarName1 'Bin1'], [largeScaleVarName2 'Bin2']}; -else - data.dimNames = {[largeScaleVarName1 'Bin'], [largeScaleVarName2 'Bin']}; -end -data.nDim = 2; -data.dimSize = nBins; -data.dimVars = binCenterValues; -data.var = v_sorted_m; -data.varName = varName; -data.dimVarUnits = {largeScaleVarData{1}.v_units, largeScaleVarData{2}.v_units}; -data.varUnits = v_units; -data.varLongName = long_name; - -status = 0; - -if ~isempty(outputFile); - status = storeDataInNetCDF(data, outputFile); -end http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/gfdl_esm2g_hus_200401_200412_Annual_sortedBy_ncar_cam5_hus_and_ncc_noresm_hus.jpeg ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/gfdl_esm2g_hus_200401_200412_Annual_sortedBy_ncar_cam5_hus_and_ncc_noresm_hus.jpeg b/public/src/conditionalSampling2Var/gfdl_esm2g_hus_200401_200412_Annual_sortedBy_ncar_cam5_hus_and_ncc_noresm_hus.jpeg deleted file mode 100644 index 8f077a3..0000000 Binary files a/public/src/conditionalSampling2Var/gfdl_esm2g_hus_200401_200412_Annual_sortedBy_ncar_cam5_hus_and_ncc_noresm_hus.jpeg and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/gfdl_esm2g_pr_200401_200412_Annual_sortedBy_gfdl_esm2g_pr_and_gfdl_esm2g_pr.jpeg ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/gfdl_esm2g_pr_200401_200412_Annual_sortedBy_gfdl_esm2g_pr_and_gfdl_esm2g_pr.jpeg b/public/src/conditionalSampling2Var/gfdl_esm2g_pr_200401_200412_Annual_sortedBy_gfdl_esm2g_pr_and_gfdl_esm2g_pr.jpeg deleted file mode 100644 index 95f5317..0000000 Binary files a/public/src/conditionalSampling2Var/gfdl_esm2g_pr_200401_200412_Annual_sortedBy_gfdl_esm2g_pr_and_gfdl_esm2g_pr.jpeg and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/octaveWrapper ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/octaveWrapper b/public/src/conditionalSampling2Var/octaveWrapper deleted file mode 100644 index 9e47564..0000000 --- a/public/src/conditionalSampling2Var/octaveWrapper +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/octave -q -addpath([pwd() '/../util/']); - -pkg load netcdf; - -arg_list = argv(); -printf ("program name: %s\n", program_name()); - -narg = length(arg_list); - -if narg < 13 - error('Insufficient argument, need specifications of the variable and environmental variables for conditional sampling: model or observation variable name!'); -end - -% Specify the data source name, in format "modelCenter_modelName" for a GCM or "dataCenter_instrument" for observational data -sourceName = lower(arg_list{1}); -varName = arg_list{2}; - -% Specify the temporal range, start/stop time in format "yyyymm" -startTimeStr = arg_list{3}; -startTime = struct('year', str2num(startTimeStr(1:4)), 'month', str2num(startTimeStr(5:6))); - -stopTimeStr = arg_list{4}; -stopTime = struct('year', str2num(stopTimeStr(1:4)), 'month', str2num(stopTimeStr(5:6))); - -% Regional boundaries: longitude and latitude boundaries -lonRange = str2num(arg_list{5}); -latRange = str2num(arg_list{6}); - -% pressure range for 3-d variable, using empty or negative values for 2-d variables -plevRange = str2num(arg_list{7}); - -% using month index within a year to select a season -monthIdx = str2num(arg_list{8}); - -% Source name for the first large scale environmental variable used for conditional sampling -% in format "modelCenter_modelName" for models and "dataCenter_instrumentName" for observational data -largeScaleSourceName1 = lower(arg_list{9}); - -% first large scale variable name as specified by the CMIP5 standard output document. -% e.g. tos for SST, omega500 for up draft etct -largeScaleVarName1 = lower(arg_list{10}); - -% Boundary values of bins for sorting the first large scale variable, expected to -% be monotonically increasing -largeScaleValueBinB1 = str2num(arg_list{11}); - -disp(largeScaleValueBinB1); -largeScaleValueBinB1 = binBoundarySpec(largeScaleValueBinB1); - -% Pressure level for the large scale variable, the longitude and latitude regions are asssumed to be the same as the physical -% variable under study. -% using empty or negative values for 2-d variables -% Note that the longitude, latitude, and time are the same for both the large scale variable -% and the physical quantity to be conditionally sampled. - -largeScalePlev1 = str2num(arg_list{12}); - -% Source name for the second large scale environmental variable used for conditional sampling -% in format "modelCenter_modelName" for models and "dataCenter_instrumentName" for observational data -largeScaleSourceName2 = lower(arg_list{13}); - -% second large scale variable name as specified by the CMIP5 standard output document. -% e.g. tos for SST, omega500 for up draft etct -largeScaleVarName2 = lower(arg_list{14}); -% Boundary values of bins for sorting the large scale variable, expected to -% be monotonically increasing -largeScaleValueBinB2 = str2num(arg_list{15}); -largeScaleValueBinB2 = binBoundarySpec(largeScaleValueBinB2); - -% Pressure level for the large scale variable, the longitude and latitude regions are asssumed to be the same as the physical -% variable under study. -% using empty or negative values for 2-d variables -% Note that the longitude, latitude, and time are the same for both the large scale variable -% and the physical quantity to be conditionally sampled. - -largeScalePlev2 = str2num(arg_list{16}); - -% Output directory name, required by the program. -output_dir = arg_list{17}; - -% display option added to determine whether to use a linear or log scales in display -% Here we encoded 3-bit information: z_bit, y_bit, x_bit -% x-axis scale: x_bit = 0 (linear), 1 (log) -% y-axis scale: y_bit = 0 (linear), 1 (log) -% z-axis scale: z_bit = 0 (linear), 1 (log), it is for the physical quantity value, so -% for a map, this represents the colormap scale. -% So displayOpt = 6 = 110 (in binary) => z_bit = 1, y_bit = 1, x_bit = 0; -% So displayOpt = 3 = 011 (in binary) => z_bit = 0, y_bit = 1, x_bit = 0; -displayOpt = str2num(arg_list{18}); - -% Printing the argument list -for ii = 1:18 -printf("%d. %s\n", ii, arg_list{ii}); -end - -dataFileFullPath = getDataFilePaths(sourceName, varName, startTime, stopTime); -largeScaleDataFileFullPath1 = getDataFilePaths(largeScaleSourceName1, largeScaleVarName1, startTime, stopTime); -largeScaleDataFileFullPath2 = getDataFilePaths(largeScaleSourceName2, largeScaleVarName2, startTime, stopTime); - -figFile = [sourceName '_' varName '_' date2Str(startTime) '_' date2Str(stopTime) '_' seasonStr(monthIdx) '_sortedBy_' largeScaleSourceName1 '_' largeScaleVarName1 '_and_' largeScaleSourceName2 '_' largeScaleVarName2 '.jpeg']; -dataFile = [sourceName '_' varName '_' date2Str(startTime) '_' date2Str(stopTime) '_' seasonStr(monthIdx) '_sortedBy_' largeScaleSourceName1 '_' largeScaleVarName1 '_and_' largeScaleSourceName2 '_' largeScaleVarName2 '.nc'] - -figFilePath = [output_dir '/' figFile]; -dataFilePath = [output_dir '/' dataFile]; -printf("figFile: %s\n", figFile) -printf("figFilePath: %s\n", figFilePath) -printf("dataFile: %s\n", dataFile) -printf("dataFilePath: %s\n", dataFilePath) - -status = -1; -displayConditionalSampling2Var(dataFileFullPath, varName, startTime, stopTime, lonRange, latRange, monthIdx, plevRange, largeScaleDataFileFullPath1, largeScaleVarName1, largeScaleValueBinB1, largeScalePlev1, largeScaleDataFileFullPath2, largeScaleVarName2, largeScaleValueBinB2, largeScalePlev2, dataFilePath, figFile, displayOpt); http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/conditionalSampling2Var/testScript ---------------------------------------------------------------------- diff --git a/public/src/conditionalSampling2Var/testScript b/public/src/conditionalSampling2Var/testScript deleted file mode 100644 index 5e56885..0000000 --- a/public/src/conditionalSampling2Var/testScript +++ /dev/null @@ -1,12 +0,0 @@ -#./octaveWrapper giss_e2-r cli 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'giss_e2-r' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 6 -#./octaveWrapper giss_e2-r clw 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'giss_e2-r' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 6 -#./octaveWrapper giss_e2-r clw 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'giss_e2-r' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' -#./octaveWrapper ncc_noresm clw 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'giss_e2-r' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' -#./octaveWrapper cccma_canesm2 cli 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'cccma_canesm2' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 0 -#./octaveWrapper cccma_canesm2 cli 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'cccma_canesm2' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 2 -#./octaveWrapper cccma_canesm2 clw 200101 200212 '0 360' '-90 90' '20000 90000' '1,2,3,4,5,6,7,8,9,10,11,12' 'cccma_canesm2' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' -#./octaveWrapper cccma_canesm2 ts 200101 200212 '0 360' '-90 90' '' '1,2,3,4,5,6,7,8,9,10,11,12' 'cccma_canesm2' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 7 -#./octaveWrapper cccma_canesm2 ts 200101 200212 '0 360' '-90 90' '' '1,2,3,4,5,6,7,8,9,10,11,12' 'cccma_canesm2' tos '294,295,296,297,298, 299, 300, 301, 302, 303, 304, 305' '' '/tmp/' 0 -#./octaveWrapper ncc_noresm cli 200101 200212 '0 360' '-90 90' '20000' '1,2,3,4,5,6,7,8,9,10,11,12' 'ncc_noresm' tos '290,303,13' '' 'ncc_noresm' 'wap' '-0.06, 0.06,6' '50000' '/tmp/' 0 -./octaveWrapper ncc_noresm cli 200101 200212 '0 360' '-60 60' '20000' '1,2,3,4,5,6,7,8,9,10,11,12' 'ncc_noresm' tos '-999999,-999999,-999999' '-999999' 'ncc_noresm' 'wap' '-0.05,0.05,5' '50000' '/tmp/' 0 -#./octaveWrapper ncc_noresm pr 200101 200312 '0 360' '-60 60' '-999999' '1,2,3,4,5,6,7,8,9,10,11,12' 'ncc_noresm' tos '280, 300, 6' '-999999' 'ncc_noresm' 'hur' '0.,100,6' '75000' '/tmp/' 0 http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/__init__.py ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/__init__.py b/public/src/correlationMap/__init__.py deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/__init__.pyc ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/__init__.pyc b/public/src/correlationMap/__init__.pyc deleted file mode 100644 index 481f776..0000000 Binary files a/public/src/correlationMap/__init__.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/call_correlationMap.py ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/call_correlationMap.py b/public/src/correlationMap/call_correlationMap.py deleted file mode 100644 index 0696cb8..0000000 --- a/public/src/correlationMap/call_correlationMap.py +++ /dev/null @@ -1,128 +0,0 @@ -# call_correlationMap.py -import string -import subprocess -import os -from os.path import basename - -if __name__ == '__main__': - import sys - sys.path.append('../time_bounds') - from getTimeBounds import correctTimeBounds2 -else: - from svc.src.time_bounds.getTimeBounds import correctTimeBounds2 - -class call_correlationMap: - def __init__(self, -model1, var1, pres1, -model2, var2, pres2, -laggedTime, start_time, end_time, lonS, lonE, latS, latE, -#months, -output_dir): - - self.model1 = model1 - self.var1 = var1 - self.pres1 = pres1 - self.model2 = model2 - self.var2 = var2 - self.pres2 = pres2 - self.laggedTime = laggedTime - self.start_time = start_time - self.end_time = end_time - self.lon1 = lonS - self.lon2 = lonE - self.lat1 = latS - self.lat2 = latE - #self.months = months - - self.output_dir = output_dir - - availableTimeBnds = correctTimeBounds2('2', - model1.replace("_", "/"), var1, model2.replace("_", "/"), - var2, start_time, end_time) - self.start_time = availableTimeBnds[0] - self.end_time = availableTimeBnds[1] - - def display(self): - - ### print 'current dir: ', os.getcwd() - # inputs: model name, variable name, start-year-mon, end-year-mon, 'start lon, end lon', 'start lat, end lat', 'mon list' - # example: ./octaveWrapper ukmo_hadgem2-a ts 199001 199512 '0,100' '-29,29' '4,5,6,10,12' - #'%g'%self.lon1 + ',' + '%g'%self.lon2 + ' ' + '%g'%self.lat1 + ',' + '%g'%self.lat2 + ' ' + \ - inputs = \ - self.model1 + ' ' + self.var1 + ' ' + self.pres1 + ' ' + \ - self.model2 + ' ' + self.var2 + ' ' + self.pres2 + ' ' + \ - str(self.laggedTime) + ' ' + \ - self.start_time + ' ' + self.end_time + ' ' + \ - self.lon1 + ',' + self.lon2 + ' ' + self.lat1 + ',' + self.lat2 + ' ' + \ - self.output_dir - #self.months + ' ' + \ - - print 'inputs: ', inputs - command = './wrapper ' + inputs - cmd = command.split(' ') - cmdstring = string.join(cmd, ' ') - print 'cmdstring: ', cmdstring - - if self.start_time == '0' or self.end_time == '0': - return ('No Data', '', '') - - try: - proc=subprocess.Popen(cmd, cwd='.', stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) - # wait for the process to finish - stdout_value, stderr_value = proc.communicate() - print 'stdout_value: ', stdout_value - print 'stderr_value: ', stderr_value - - if stderr_value.find('error:') >= 0: - return (stderr_value, '') - - fst = 'figFile: ' - l1 = len(fst) - ### print 'l1: ', l1 - image_filename = '' - - fst2 = 'dataFile: ' - l2 = len(fst2) - ### print 'l2: ', l2 - data_filename = '' - - lines = stdout_value.split('\n') - for line in lines: - ### print '*****: ', line - if line.find('figFile: ') >= 0: - print '***** line: ', line - image_filename = line[l1:] - - if line.find('dataFile: ') >= 0: - print '***** line: ', line - data_filename = line[l2:] - - image_filename = os.path.basename(image_filename) - print 'image_filename: ', image_filename - data_filename = os.path.basename(data_filename) - print 'data_filename: ', data_filename - return (stdout_value, image_filename, data_filename) - except OSError, e: - err_mesg = 'The subprocess "%s" returns with an error: %s.' % (cmdstring, e) - return (err_mesg, '', '') - - -if __name__ == '__main__': - - c1 = call_scatterPlot2V(\ - 'ukmo_hadgem2-a', 'ts', '200', 'ukmo_hadgem2-a', 'clt', '200', '5', '199001', '199512', '0', '100', '-29', '29', \ - '/home/svc/cmac/trunk/services/svc/svc/static/scatterPlot2V') - - mesg = c1.display() - print 'mesg: ', mesg - - - """ - c1 = call_scatterPlot2V(\ - 'ukmo_hadgem2-a', 'ts', '200', 'ukmo_hadgem2-a', 'clt', '200', '199001', '199512', '0', '100', '-29', '29', 500, \ - '/home/svc/cmac/trunk/services/svc/svc/static/diffPlot2V', 1) - - mesg = c1.display() - print 'mesg: ', mesg - """ - http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/call_correlationMap.pyc ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/call_correlationMap.pyc b/public/src/correlationMap/call_correlationMap.pyc deleted file mode 100644 index 10ccf41..0000000 Binary files a/public/src/correlationMap/call_correlationMap.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/pythonWrapper ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/pythonWrapper b/public/src/correlationMap/pythonWrapper deleted file mode 100644 index 98be319..0000000 --- a/public/src/correlationMap/pythonWrapper +++ /dev/null @@ -1,909 +0,0 @@ -#!/home/svc/install/epd/bin/python -''' -execfile('/home/bytang/projects/cmac/trunk/services/svc/svc/src/randomForest/pythonWrapper') - -import os -os.chdir('/home/svc/cmac/trunk/services/svc/svc/src/correlationMap') -execfile('pythonWrapper') - - -''' -HOME='/home/svc' - -cr = { -# 1 2 3 4 -# -'import_': 1, # 0 1 1 0 -# parameters_ -# def_change_labels: # not working -# def_getRootDir(): -# def_extractNC(desFn): -# def_clipEnd(x, w, percL, percR): -# class_SUBSET_REGION(): - # def_noDataExit() - # def_getFileName2 - # def_getFileName - # def_getUnits(self): - # def_subsetting(): - # def_loadFile - # def_corr # - # def_saveData(self): -'init_class': 1, # 1 1 -'command_arg': 1, # 1 1 -'plot__': 1, # 1 1 -'': 0, # 1 1 -'': 0, # 1 1 -} - -#if cr[''] == 1: -#if cr[''] == 1: - -# 1 -- -# - -if cr['import_'] == 1: - import os, sys, time - import tempfile - #import math - import glob - import re - - import numpy as np - from netCDF4 import Dataset - import netCDF4 as nC4 - sys.path.insert(0, '../util') - import NC_btang_v4 as NC1 - - import matplotlib - matplotlib.use('Agg') - import matplotlib.pylab as Mat - Mat.ioff() - from mpl_toolkits.basemap import Basemap - -t00 = time.time() - -# parameters_ -num2month = { -1: 'JAN', -2: 'FEB', -3: 'MAR', -4: 'APR', -5: 'MAY', -6: 'JUN', -7: 'JUL', -8: 'AUG', -9: 'SEP', -10: 'OCT', -11: 'NOV', -12: 'DEC', -} - -modelCenter = [ -'cccma', -'csiro', -'gfdl', -'giss', -'ipsl', -'miroc', -'ncar', -'ncc', -'ukmo', -] - -obsCenter = [ -'nasa', -'noaa', -'argo', -] - -oceanVar = [ -'ot', -'os', -] - -var3d = [ -'ta', -'hus', -'clw', -'cli', -'ot', -'os', -] - -regridVar = [ -'cli', -'clw', -] - -# def_change_labels(ax): -def change_labels(ax): - x1 = Mat.getp(ax, 'xticklabels') - #x1 = Mat.getp(ax.xaxis, 'ticklabels') # not working - x1New = [] - for i in range(len(x1)): - t1 = Mat.getp(x1[i], 'text') - print t1 - if not t1: - t2 = '' - elif t1[0]==u'\u2212': - t2 = str(t1[1:]) + 'W' - elif t1[0]==u'0': - t2 = str(t1) - else: - t2 = str(t1) + 'E' - x1New.append(t2) - # - x1 = Mat.getp(ax, 'yticklabels') - - y1New = [] - for i in range(len(x1)): - t1 = Mat.getp(x1[i], 'text') - if not t1: - t2 = '' - elif t1[0]==u'\u2212': - t2 = str(t1[1:]) + 'S' - elif t1[0]==u'0': - t2 = str(t1) - else: - t2 = str(t1) + 'N' - y1New.append(t2) - Mat.setp(ax, xticklabels=x1New, yticklabels=y1New) - return x1New, y1New - -# def_getRootDir(): -def getRootDir(): - # use data.cfg to set the data root dir. - - # assuming the cwd is in src/* - configFile = '../../../data.cfg' - - # if not, use 'trunk' to figure it out - #if not os.path.isfile(configFile): - if 1: - cwd = os.getcwd() - ind1 = cwd.find('trunk') - if ind1>-1: - cmacDir = cwd[:ind1] - configFile = cmacDir + '/trunk/services/svc/data.cfg' - - if not os.path.isfile(configFile): - print 'failed to find data.cfg.' - return None - - try: - temp1 = open(configFile).read() - if temp1[-1]=='\n': - temp1 = temp1[:-1] - if temp1[-1]=='/': - temp1 = temp1[:-1] - if os.path.isdir(temp1): - dataDir = temp1 + '/cmip5' - #a.dataDir = temp1 # should change to this when data.cfg is without 'cmip5' - return dataDir, cmacDir - - except: - print 'failed to read data.cfg.' - return None - - print 'failed to get data.cfg.' - return None - -# def_extractNC(desFn): -p1 = re.compile("S_FILENAME += *\'(.+\.nc)\'") -def extractNC(desFn): - lines = open(desFn).read() - # S_FILENAME = '/mnt/r1i1p1_plevRegridded_198412-200511.nc' - - m1 = p1.search(lines) - return m1.groups()[0] - -# def_clipEnd(x, w, percL, percR): -def clipEnd(x, w, percL, percR): - indS = np.argsort(x) - x1 = x[indS] - w1 = w[indS] - sum1 = np.cumsum(w1) - threshL = sum1[-1]*percL - threshR = sum1[-1]*(1.0 - percR) - indL = max( np.searchsorted(sum1, threshL) - 1, 0 ) - indR = min( np.searchsorted(sum1, threshR) + 1, len(x) ) - - return x1[indL], x1[indR] - -# class_SUBSET_REGION(): -class SUBSET_REGION(): - #== def___init__ - def __init__(self): - self.dataDir, self.cmacDir = getRootDir() - if self.dataDir is None: - sys.exit(1) - - self.scatterDir = '%s/trunk/services/svc/svc/src/scatterPlot2V'%self.cmacDir - - ### self.ferretCmd = '/home/bytang/install/bin/ferret' - # /mnt/xvdf/data/ - if self.dataDir.find('xvdf')>-1: - self.ferretCmd = '/home/sflops/install/bin/ferret' - else: - self.ferretCmd = '/home/svc/install/bin/ferret' - - self.clipL = 0.02 - self.clipR = 0.02 - - self.ferretMem = 100 - self.isDiffPlot = 0 - - #self.dataDir = '/mnt/hgfs/cmacws/data1/data/cmip5' - ### self.desDir = '/home/bytang/projects/cmac/des/original' - #self.desDir = '/home/svc/cmac/des/original' - - # zzzz - #self.desDir = '/home/bytang/projects/cmac/tmp/des' # for Benyang's testing - self.desDir = os.path.split(self.dataDir)[0] + '/des' # for deployment - #self.desDir = '%s/des'%self.scatterDir # ad hoc fix for summer school - - if 0: - self.lon1S = -10.5 - self.lon1E = 20.3 - #self.dLon = 1.0 - - if 0: - self.lon1S = -180.0 - self.lon1E = 180.0 - #self.dLon = 1.0 - - if 0: - self.lat1S = -70.1 - self.lat1E = -20.9 - #self.dLat = 1.0 - - if 1: - self.lon1S = -180.0 - self.lon1E = 180.0 - - if 1: - self.lat1S = -80.0 - self.lat1E = 80.0 - -# - if 1: - self.nVar = 2 - self.center = [] - self.model = [] - self.varName = [] - self.pres = [] - - if 0: - self.center.append('gfdl') - self.model.append('cm3') - self.varName.append('ts') - self.pres.append(200*100) - - if 0: - self.center.append('gfdl') - self.model.append('cm3') - self.varName.append('ts') - self.pres.append(200*100) - - if 1: - self.center.append('gfdl') - self.model.append('esm2g') - self.varName.append('lai') - self.pres.append(200*100) - - if 1: - self.center.append('gfdl') - self.model.append('esm2g') - self.varName.append('zos') - self.pres.append(200*100) - - self.laggedTime = 1 - self.yearS = 2004 - self.yearE = 2004 - - self.monthS = 1 - self.monthE = 12 - - self.dayS = 15 - self.dayE = 15 - - self.nSample = 500 - - self.outDir = '.' - - self.noData = None - - #== def_derived - def derived(self): - pass - - # def_noDataExit() - def noDataExit(self, msg): - print "No Data !!!" - print msg - sys.exit(1) - - # not used. Use the des file instead. - # def_getFileName(self, center, model, varName): - def getFileName(self, center, model, varName): - # the original is just for model - if center in modelCenter: - if varName in regridVar: - dir0 = '%s/%s/%s/regridded'%(self.dataDir, center, model) - else: - dir0 = '%s/%s/%s/original'%(self.dataDir, center, model) - - else: - dir0 = '%s/%s/%s'%(self.dataDir, center, model) - - desDir = self.desDir - - filesNc = glob.glob('%s/%s_*.nc'%(dir0, varName)) - desFn = '%s/%s_%s_%s.des'%(desDir, center, model, varName) - filesDes = glob.glob(desFn) - if 1: - print dir0 - print 'filesNc, filesDes:' - print center, model, varName - print filesNc - print filesDes - - # yyyy - if len(filesNc)==0: - self.noDataExit('no *.nc file.') - - if len(filesDes)>1: - print 'more than 1 des files:' - for f in filesDes: - print f - - self.noDataExit('more than 1 *.des files.') - return None - - if len(filesNc)>1 and len(filesDes)==1: - return filesDes[0], filesNc[0] - - if len(filesNc)>1 and len(filesDes)==0: - try: - temp1 = '/home/bytang/bin/mine/mkdes2 --f90 --des %s %s/%s_*.nc'%(desFn, dir0, varName) - print temp1 - os.system(temp1) - files2a = glob.glob(desFn) - return files2a[0], filesNc[0] - except: - self.noDataExit('failed to generate the des file.') - - if len(filesNc)==1: - return filesNc[0], filesNc[0] - - return None - - # def_getFileName2(self, center, model, varName): - def getFileName2(self, center, model, varName): - dir0 = '%s/%s_%s'%(self.desDir, center, model) - fileNc = glob.glob('%s/%s.nc'%(dir0, varName)) - #print '%s/%s.nc'%(dir0, varName) - if len(fileNc)>0: - return fileNc[0], fileNc[0] - - else: - #print '%s/%s.des'%(dir0, varName) - fileDes = glob.glob('%s/%s.des'%(dir0, varName)) - - if len(fileDes)==0: - return None - - # def_extractNC(desFn): - return fileDes[0], extractNC(fileDes[0]) - - # def_getUnits(self): - def getUnits(self): - self.units = [] - for iVar in range(self.nVar): - nc1 = Dataset(self.inFileNc[iVar], 'r') - data = nc1.variables[self.varName[iVar]] - self.units.append(data.units) - nc1.close() - - # def_subsetting(): - def subsetting(self, ncFile1, varName1, ncFile2=None, varName2='DATA1', - varNameOut='DATA1', interp='', dim=4, lev=-1, isAve=0): - - try: - temp1 = os.path.isfile(ncFile1) - except: - print 'Subsetting failed; file not there: %s'%(ncFile1) - self.noData = 1 - tempFile = None - return tempFile - - if not os.path.isfile(ncFile1): - print 'Subsetting failed; file not there: %s'%(ncFile1) - self.noData = 1 - tempFile = None - return tempFile - - aveStr = '' - if isAve==1: - aveStr = '@ave' - - if self.noData ==1: - self.noDataExit('in subsetting: nc file is not there.') - - tempFile = tempfile.mkstemp(suffix='.nc', dir=self.outDir) - - tmpFileJnl = tempfile.mkstemp(suffix='.jnl', dir=self.outDir) - #print varName, tempFile, tmpFileJnl - - dimStr = '' - if dim==3: - dimStr = ', t="15-%s-%d":"15-%s-%d"%s'\ -%(num2month[self.monthS], self.yearS, num2month[self.monthE], self.yearE, aveStr) - elif dim==4: - if lev<0: - dimStr = ', k=1, t="15-%s-%d":"15-%s-%d"%s'\ -%(num2month[self.monthS], self.yearS, num2month[self.monthE], self.yearE, aveStr) - else: - dimStr = ', z=%g@itp, t="15-%s-%d":"15-%s-%d"%s'\ -%(lev, num2month[self.monthS], self.yearS, num2month[self.monthE], self.yearE, aveStr) - - if 0: - dimStr = ', k=1, t="15-%s-%d":"15-%s-%d"%s'\ -%(num2month[self.monthS], self.yearS, num2month[self.monthE], self.yearE, aveStr) - - # - if ncFile2 is None: - script1 = ''' - SET MEMORY/SIZE=%d - show memory - SET mode desperate:100000 - - ! 3 - use "%s" - !show data - - !define var/bad=-9999.0/title="aa" data1 =SST[d=1, g=newG@nrst, l=1] - ! This is too slow: - !define var/bad=-9999.0/title="aa" data1 =SST[d=1, g=newG@ave, l=1] - ! Default is linear interpolation. As fast as nrst: - ! 4 - define var/bad=-9999.0/title="aa" %s =%s[d=1, x=%f:%f, y=%f:%f %s] - ! 5 - save/clobber/file="%s" %s - '''%( - self.ferretMem, - # 3 - ncFile1, - # 4 - varNameOut, - varName1, - self.lon1S, - self.lon1E, - self.lat1S, - self.lat1E, - #interp, - dimStr, - # 5 - tempFile[1], - varNameOut) - - else: - script1 = ''' - SET MEMORY/SIZE=%d - show memory - SET mode desperate:100000 - - ! 3 - use "%s" - use "%s" - !show data - - - !define var/bad=-9999.0/title="aa" data1 =SST[d=1, g=newG@nrst, l=1] - ! This is too slow: - !define var/bad=-9999.0/title="aa" data1 =SST[d=1, g=newG@ave, l=1] - ! Default is linear interpolation. As fast as nrst: - ! 4 - define var/bad=-9999.0/title="aa" %s =%s[d=1, g=%s[d=2, l=1]%s %s] - ! 5 - save/clobber/file="%s" %s - '''%( - self.ferretMem, - # 3 - ncFile1, - ncFile2, - # 4 - varNameOut, - varName1, - varName2, - interp, - dimStr, - # 5 - tempFile[1], - varNameOut) - - open(tmpFileJnl[1], 'w').write(script1) - - temp1 = '%s -gif -script %s' %(self.ferretCmd, tmpFileJnl[1]) - - try: - os.system(temp1) - except: - self.noDataExit('subsetting: failed to run ferret') - - #os.remove(tmpFileJnl) - - if not os.path.isfile(tempFile[1]): - self.noDataExit('subsetting: ferret failed to generate a nc file.') - - if os.stat(tempFile[1]).st_size<10: - self.noDataExit('subsetting: ferret failed to generate a nc file.') - - return tempFile[1] - - # def_loadFile - def loadFile(self, ncFile, varName='DATA1'): - nc1 = Dataset(ncFile, 'r') - data = nc1.variables[varName][:] - nc1.close() - - #zzzz - if len(data.shape)==3: - data = data[0, :,:] - return data - - # def_corr # - def corr(self, ncFile1, ncFile2, varName1='DATA1', varName2='DATA2'): - nBin = 30 - nBin1 = 40 - - # open file - nc1 = Dataset(ncFile1, 'r') - nc2 = Dataset(ncFile2, 'r') - - ncVar1 = nc1.variables[varName1] - ncVar2 = nc2.variables[varName2] - - dims1 = ncVar1.dimensions - lon1 = nc1.variables[dims1[-1]][:] - lat1 = nc1.variables[dims1[-2]][:] - - dims2 = ncVar2.dimensions - lon2 = nc2.variables[dims2[-1]][:] - lat2 = nc2.variables[dims2[-2]][:] - - print ncVar1.shape - - nMonth = ncVar1.shape[0] - - # loop over time - monthCount = 0 - for iMonth in range(self.laggedTime, nMonth): - monthCount += 1 - a1 = ncVar1[iMonth-self.laggedTime] - a2 = ncVar2[iMonth] - - # sometimes the 2 data may not have the save shape - if (a1.shape[-1] != a2.shape[-1]): - min1 = min(a1.shape[-1], a2.shape[-1]) - a1 = a1[:, :min1] - a2 = a2[:, :min1] - - if (a1.shape[0] != a2.shape[0]): - min1 = min(a1.shape[0], a2.shape[0]) - a1 = a1[:min1,:] - a2 = a2[:min1,:] - - # remove the invalid data - if 0: - temp1 = np.ma.arange(5) - valid1 = np.ones( a1.shape ) - valid2 = np.ones( a1.shape ) - if type(a1) == type(temp1): - if a1.mask is not None: - valid1 = ~( a1.mask ) - if type(a2) == type(temp1): - if a2.mask is not None: - valid2 = ~( a2.mask ) - - valid = valid1 & valid2 - aa1 = a1[valid] - aa2 = a2[valid] - - aa1 = aa1.ravel() - aa2 = aa2.ravel() - - if monthCount==1: - xb = a1 - yb = a2 - xyb = a1*a2 - xxb = a1*a1 - yyb = a2*a2 - else: - xb += a1 - yb += a2 - xyb += a1*a2 - xxb += a1*a1 - yyb += a2*a2 - - nc1.close() - nc2.close() - - # calc corr - xb /= float(monthCount) - yb /= float(monthCount) - xyb /= float(monthCount) - xxb /= float(monthCount) - yyb /= float(monthCount) - - print 'xb: ' - print xb.min(), xb.max(), xb.mean(), xb.std() - - print 'yb: ' - print yb.min(), yb.max(), yb.mean(), yb.std() - - print 'xyb: ' - print xyb.min(), xyb.max(), xyb.mean(), xyb.std() - - print 'xxb: ' - print xxb.min(), xxb.max(), xxb.mean(), xxb.std() - - print 'yyb: ' - print yyb.min(), yyb.max(), yyb.mean(), yyb.std() - - temp1 = np.sqrt( (xxb-xb*xb)*(yyb-yb*yb) ) - temp2 = temp1<1e-10 - temp1[temp2] = 1.0 - - temp3 = (xyb - xb*yb) - corrxy = temp3/temp1 - corrxy = np.ma.array(corrxy) - corrxy[temp2] = np.ma.masked - - print 'corrxy: ' - print corrxy.min(), corrxy.max(), corrxy.mean(), corrxy.std() - - # figure - fig1 = Mat.figure(figsize=(10,16)) - Mat.clf() - - # plot correlation map - Mat.subplot(3,1,1) - #fig1.tight_layout() - - fig1.tight_layout() - m1 = Basemap(self.lon1S, self.lat1S, self.lon1E, self.lat1E, resolution='c', suppress_ticks=False) - temp1 = m1.pcolor(lon1, lat1, corrxy, vmin=-1.0, vmax=1.0) - #temp1 = m1.pcolor(lon1, lat1, corrxy) - temp1 = m1.drawcoastlines() - Mat.colorbar() - Mat.title('corrcoef(%s_%s:%s , %s_%s:%s(lag=%d)). # of month: %d'\ - %(a.center[0], a.model[0], a.varName[0], a.center[1], a.model[1], a.varName[1], - a.laggedTime, - monthCount)) - - #change_labels(Mat.gca()) - # output png file - figFile = '%s/corrcoef.png'%self.outDir - Mat.savefig(figFile, dpi=100) - - print 'figFile: %s'%figFile - - # def_saveData(self): - def saveData(self, tempFile1, tempFile2): - fn = '%s/data_compare.nc'%self.outDir - - # load data - nc1 = Dataset(tempFile1, 'r') - data1a = nc1.variables['DATA1'] - dims1 = data1a.dimensions - data1 = data1a[:] - lon1 = nc1.variables[dims1[-1]][:] - lat1 = nc1.variables[dims1[-2]][:] - - nDim1 = len(data1.shape) - if nDim1==3: - time1 = nc1.variables[dims1[0]][:] - - nc1.close() - - nc2 = Dataset(tempFile2, 'r') - data2a = nc2.variables['DATA2'] - dims2 = data2a.dimensions - data2 = data2a[:] - lon2 = nc2.variables[dims2[-1]][:] - lat2 = nc2.variables[dims2[-2]][:] - - nDim2 = len(data2.shape) - if nDim2==3: - time2 = nc2.variables[dims2[0]][:] - - nc2.close() - - # sometimes the 2 data may not have the save shape - nLon = min( len(lon1), len(lon2) ) - nLat = min( len(lat1), len(lat2) ) - if len(lon1)>nLon or len(lat1)>nLat: - lon1 = lon1[:nLon] - lat1 = lat1[:nLat] - data1 = data1[..., :nLat, :nLon] - - if len(lon2)>nLon or len(lat2)>nLat: - lon2 = lon2[:nLon] - lat2 = lat2[:nLat] - data2 = data2[..., :nLat, :nLon] - - # fill the missing data - if type(data1)==type(np.ma.arange(1)): - data1a = data1.filled(-9999.0) - else: - data1a = data1 - - if type(data2)==type(np.ma.arange(1)): - data2a = data2.filled(-9999.0) - else: - data2a = data2 - - # save the 2 variables - if nDim1==2: - NC1.save2nc(data1a, ncfile=fn, name='data1', - newfile=1, - format='NETCDF3_CLASSIC', - missing_value=-9999.0, - axisorder='yx', axislib=NC1.axislib0, axisarray=[lat1, lon1]) - else: - NC1.save2nc(data1a, ncfile=fn, name='data1', - newfile=1, - format='NETCDF3_CLASSIC', - missing_value=-9999.0, - axisorder='tyx', axislib=NC1.axislib0, axisarray=[time1,lat1, lon1]) - - nc1 = Dataset(fn, 'r+') - - if nDim2==2: - d2 = nc1.createVariable('data2', 'float32', ('lat', 'lon')) - else: - d2 = nc1.createVariable('data2', 'float32', ('time', 'lat', 'lon')) - - #print d2.shape - #print data2.shape - # zzzz - #nn0 = min( d2.shape[0], data2.shape[0]) - #nn1 = min( d2.shape[1], data2.shape[1]) - d2[:] = data2a - nc1.close() - - print 'dataFile: %s'%fn - -if cr['init_class'] == 1: - a = SUBSET_REGION() - -if cr['command_arg'] == 1: - - ''' -- interface: - nVar - repeat nVar times: - model1 - var1 - lavel1 - laggedTime - months - lon1,lon2 - lat1,lat2 - outDir -''' - # inputs = \ - # self.model1 + ' ' + self.var1 + ' ' + self.start_time1 + ' ' + self.end_time1 + ' ' + \ - # self.lon1a + ',' + self.lon1b + ' ' + self.lat1a + ',' + self.lat1b + ' ' + \ - # self.model2 + ' ' + self.var2 + ' ' + self.start_time2 + ' ' + self.end_time2 + ' ' + \ - # self.lon2a + ',' + self.lon2b + ' ' + self.lat2a + ',' + self.lat2b + ' ' + \ - # self.output_dir - - if len(sys.argv)>1: - argv = sys.argv - - print 'len(argv) = ', - print len(argv) - print 'argv: ' - for i in argv: - print i - - # arg 1 - a.nVar = 2 - - a.center = [] - a.model = [] - a.varName = [] - a.pres = [] - ii = 0 - for iVar in range(a.nVar): - # arg 2 - ii += 1 - temp1 = argv[ii].split('_') - a.center.append(temp1[0]) - a.model.append(temp1[1]) - - # arg 3 - ii += 1 - a.varName.append(argv[ii]) - - # arg 4 - if 1: - ii += 1 - try: - pres1 = float(argv[ii]) - except ValueError: - pres1 = -1 - if pres1>0 and (a.varName[iVar] not in oceanVar): - pres1 *= 100.0 - a.pres.append(pres1) - - ii += 1 - temp1 = argv[ii] - a.laggedTime = int(temp1) - - ii += 1 - a.yearS = int(argv[ii][:4]) - a.monthS = int(argv[ii][4:]) - - # arg 8 - ii += 1 - a.yearE = int(argv[ii][:4]) - a.monthE = int(argv[ii][4:]) - - # arg 11 - ii += 1 - temp1 = argv[ii].split(',') - a.lon1S = float(temp1[0]) - a.lon1E = float(temp1[1]) - - # arg 12 - ii += 1 - temp1 = argv[ii].split(',') - a.lat1S = float(temp1[0]) - a.lat1E = float(temp1[1]) - - # arg 10 - if 0: - ii += 1 - temp1 = argv[ii].split(',') - a.months = [int(i) for i in temp1] - if a.months[0]==-1: - a.months = range(1,13) - - # arg 13 - ii += 1 - a.outDir = argv[ii] - print 'a.outDir: ', - print a.outDir - -if cr['plot__'] == 1: - # get file names - #try: - a.inFile = [] - a.inFileNc = [] - for iVar in range(a.nVar): - if 1: - inFile1, inFile1Nc = a.getFileName2(a.center[iVar], a.model[iVar], a.varName[iVar]) - a.inFile.append(inFile1) - a.inFileNc.append(inFile1Nc) - print 'variable ', iVar - print a.center[iVar], a.model[iVar], a.varName[iVar] - print a.inFile[-1] - print a.inFileNc[-1] - - a.getUnits() - - # subset - tempFile1 = a.subsetting(a.inFile[0], a.varName[0], dim=4, lev=a.pres[0]) - tempFile2 = a.subsetting(a.inFile[1], a.varName[1], ncFile2=tempFile1, varNameOut='DATA2', dim=4, lev=a.pres[1]) - - if 1: - a.corr(tempFile1,tempFile2) - - #a.saveData(tempFile1, tempFile2) - - print 'tempFiles:' - print tempFile1 - print tempFile2 http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/correlationMap/wrapper ---------------------------------------------------------------------- diff --git a/public/src/correlationMap/wrapper b/public/src/correlationMap/wrapper deleted file mode 100644 index 2559755..0000000 --- a/public/src/correlationMap/wrapper +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -/home/svc/install/bin/epd ./pythonWrapper $* - http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/__init__.py ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/__init__.py b/public/src/regridAndDownload/__init__.py deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/__init__.pyc ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/__init__.pyc b/public/src/regridAndDownload/__init__.pyc deleted file mode 100644 index 59debc3..0000000 Binary files a/public/src/regridAndDownload/__init__.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/call_regridAndDownload.py ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/call_regridAndDownload.py b/public/src/regridAndDownload/call_regridAndDownload.py deleted file mode 100644 index 8e02bb8..0000000 --- a/public/src/regridAndDownload/call_regridAndDownload.py +++ /dev/null @@ -1,99 +0,0 @@ -# call_twoDimMap.py -import string -import subprocess -import os -from os.path import basename - -if __name__ == '__main__': - import sys - sys.path.append('../time_bounds') - from getTimeBounds import correctTimeBounds1 -else: - from svc.src.time_bounds.getTimeBounds import correctTimeBounds1 - -class call_regridAndDownload: - def __init__(self, model, var, start_time, end_time, lon1, lon2, dlon, lat1, lat2, dlat, plev, output_dir): - self.model = model - self.var = var - self.lon1 = lon1 - self.lon2 = lon2 - self.dlon = dlon - self.lat1 = lat1 - self.lat2 = lat2 - self.dlat = dlat - self.plev = plev - self.output_dir = output_dir - availableTimeBnds = correctTimeBounds1('1', model.replace("_", "/"), var, start_time, end_time) - self.start_time = availableTimeBnds[0] - self.end_time = availableTimeBnds[1] - - # temporary fix - # This application level knowledge may not belong here - if self.model == 'NASA_AMSRE' and self.var == 'ts': - self.var = 'tos' - - - def regridAndDownload(self): - - ### print 'current dir: ', os.getcwd() - # inputs: model name, variable name, start-year-mon, end-year-mon, 'start lon, end lon', 'start lat, end lat', 'mon list' - # example: ./octaveWrapper ukmo_hadgem2-a ts 199001 199512 '0,100' '-29,29' '4,5,6,10,12' - inputs = self.model + ' ' + self.var + ' ' + self.start_time + ' ' + self.end_time + ' ' + \ - self.lon1 + ',' + self.lon2 + ',' + self.dlon + ' ' + self.lat1 + ',' + self.lat2 + ',' + self.dlat + ' ' + \ - self.plev + ' ' + self.output_dir - print 'inputs: ', inputs - command = './octaveWrapper ' + inputs - cmd = command.split(' ') - cmdstring = string.join(cmd, ' ') - print 'cmdstring: ', cmdstring - - if self.start_time == '0' or self.end_time == '0': - return ('No Data', '', '') - - try: - proc=subprocess.Popen(cmd, cwd='.', stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) - # wait for the process to finish - stdout_value, stderr_value = proc.communicate() - print 'stdout_value: ', stdout_value - print 'stderr_value: ', stderr_value - - if stderr_value.find('error:') >= 0: - return (stderr_value, '', '') - - fst = 'figFile: ' - l1 = len(fst) - ### print 'l1: ', l1 - image_filename = '' - - fst2 = 'dataFile: ' - l2 = len(fst2) - ### print 'l2: ', l2 - data_filename = '' - - lines = stdout_value.split('\n') - for line in lines: - ## print '*****: ', line - if line.find('figFile: ') >= 0: - print '***** line: ', line - image_filename = line[l1:] - - if line.find('dataFile: ') >= 0: - print '***** line: ', line - data_filename = line[l2:] - - print 'image_filename: ', image_filename - print 'data_filename: ', data_filename - return (stdout_value, image_filename, data_filename) - except OSError, e: - err_mesg = 'The subprocess "%s" returns with an error: %s.' % (cmdstring, e) - return (err_mesg, '', '') - - -if __name__ == '__main__': - ### c1 = call_twoDimMap('ukmo_hadgem2-a', 'ts', '199001', '199512', '0', '100', '-29', '29', '4,5,6,10,12', '/home/svc/cmac/trunk/services/twoDimMap/twoDimMap/static/') - ### c1 = call_twoDimMap('cccma_canam4', 'ts', '199001', '199512', '0', '100', '-29', '29', '4,5,6,10,12', '/home/svc/cmac/trunk/services/twoDimMap/twoDimMap/static/') - c1 = call_regridAndDownload('ncc_noresm', 'ta', '199001', '200012', '0', '360', '4', '-90', '90', '4', '100000,80000,50000,30000,20000,10000', './') - ### c1 = call_twoDimMap('ukmo_hadgem2-es', 'ts', '199001', '199512', '0', '100', '-29', '29', '4,5,6,10,12', '/home/svc/cmac/trunk/services/twoDimMap/twoDimMap/static/') - - mesg = c1.regridAndDownload() - print 'mesg: ', mesg http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/call_regridAndDownload.pyc ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/call_regridAndDownload.pyc b/public/src/regridAndDownload/call_regridAndDownload.pyc deleted file mode 100644 index 42b6191..0000000 Binary files a/public/src/regridAndDownload/call_regridAndDownload.pyc and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/octaveWrapper ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/octaveWrapper b/public/src/regridAndDownload/octaveWrapper deleted file mode 100644 index f8c12dd..0000000 --- a/public/src/regridAndDownload/octaveWrapper +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/octave -q -addpath([pwd() '/../util/']); - -pkg load netcdf; -arg_list = argv(); -printf ("program name: %s\n", program_name()); - -narg = length(arg_list); - -if narg < 2 - error('Insufficient argument, need a model and a variable name!'); -end -sourceName = lower(arg_list{1}); -printf ("sourceName: %s\n", sourceName); -varName = arg_list{2}; -printf ("varName: %s\n", varName); - -if narg > 2 - startTimeStr = arg_list{3}; - startTime = struct('year', str2num(startTimeStr(1:4)), 'month', str2num(startTimeStr(5:6))); -end - -if narg > 3 - stopTimeStr = arg_list{4}; - stopTime = struct('year', str2num(stopTimeStr(1:4)), 'month', str2num(stopTimeStr(5:6))); -end - -% Default grid, 2 x 2.5 deg, MLS grid -lon = 2.5*(0:143); -lat = 2*(-45:45); - -if narg > 4 - lon_grid = str2num(arg_list{5}); - printf ("longitude grid (min, max, resolution): (%d, %d, %d) \n", lon_grid(1), lon_grid(2), lon_grid(3)); - lon = lon_grid(1):lon_grid(3):lon_grid(2); -end - -if narg > 5 - lat_grid = str2num(arg_list{6}); - printf ("latitude grid (min, max, resolution): (%d, %d, %d) \n", lat_grid(1), lat_grid(2), lat_grid(3)); - lat = lat_grid(1):lat_grid(3):lat_grid(2); -end - -% Default CMIP5 pressure levels -plev = plevForRegrid(); - -if narg > 6 - plev = str2num(strrep(arg_list{7}, ',', ' ')); - printf ("pressure levels : %s Pa\n", arg_list{5}); -end - -outputDir = '/tmp/'; -if narg > 7 - outputDir = arg_list{8}; -end - -overwrite = true; -if narg > 8 - overwrite = str2num(arg_list{9}); -end - -for ii = 1:narg - printf("%d. %s\n", arg_list{ii}, ii) -end - -dataFileFullPath = getDataFilePaths(sourceName, varName, startTime, stopTime); - -nFile = length(dataFileFullPath); - -disp(nFile) - -outFiles = cell(nFile,1); - -regridStr = strrep(strrep([arg_list{5} '_' arg_list{6} '_' arg_list{7}], ' ' , ''), ',', 'f'); - -for fileI = 1:nFile - thisInputFile = dataFileFullPath{fileI}; - [thisPath, thisName] = fileparts(thisInputFile); - outFiles{fileI} = [outputDir '/' thisName '_' regridStr '.nc']; - disp(outFiles{fileI}) - if exist(outFiles{fileI}, 'file') - if overwrite - delete(outFiles{fileI}); - else - continue; - end - end - status = regridAndDownload(thisInputFile, outFiles{fileI}, varName, lon, lat, plev); -end - -dataFile = [sourceName '_' varName '_' date2Str(startTime) '_' date2Str(stopTime) '_' regridStr '.nc']; -dataFilePath = [outputDir '/' dataFile]; - -% Let us concatenate all the outpout files -cmd = ['/usr/bin/ncrcat '] -for ii = 1:nFile - cmd = [cmd outFiles{ii} ' ']; -end -cmd = [cmd dataFilePath]; -system(cmd); -for ii = 1:nFile - delete(outFiles{ii}); -end - -printf("dataFile: %s\n", dataFile) -printf("dataFilePath: %s\n", dataFilePath) http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/regridAndDownload.m ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/regridAndDownload.m b/public/src/regridAndDownload/regridAndDownload.m deleted file mode 100644 index 485c294..0000000 --- a/public/src/regridAndDownload/regridAndDownload.m +++ /dev/null @@ -1,28 +0,0 @@ -function status = regridAndDownload(inputFile, outputFile, varName, lon, lat, plev) -% -% This function regrids data in input file according to the specified longitude, latitude, pressure level -% and output the data to output file -% -status = -1; - -if nargin < 4 - status = system(['/bin/ln -s ' inputFile ' ' outputFile ';']); - return; -end - -outputFile_tmp = [outputFile(1:(end-3)) '_tmp.nc']; - -if ~isempty(lon) && ~isempty(lat) - disp('regridding longitude and latitude ...'); - status = regridLonAndLat(inputFile, outputFile_tmp, varName, lon, lat); -else - status = system(['/bin/ln -s ' inputFile ' ' outputFile_tmp ';']); -end - -if abs(plev(1) - (-999999.0)) < 1 - movefile(outputFile_tmp, outputFile); -else - disp('regridding vertical levels ...'); - status = resampleVerticalGrid(outputFile_tmp, outputFile, varName, plev); - delete(outputFile_tmp); -end http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/011075b9/public/src/regridAndDownload/testScript ---------------------------------------------------------------------- diff --git a/public/src/regridAndDownload/testScript b/public/src/regridAndDownload/testScript deleted file mode 100644 index 301cddc..0000000 --- a/public/src/regridAndDownload/testScript +++ /dev/null @@ -1,7 +0,0 @@ -#./octaveWrapper '/mnt/hgfs/cmacws/data1/data/cmip5/giss/e2-r/amip/ta_Amon_GISS-E2-R_amip_r1i1p1_188001-195012.nc' 'ta' '0, 360, 4', '-90, 90, 4', '100000,80000,50000,30000, 20000, 10000', 1 /tmp/xxx2.nc; - -#./octaveWrapper '/mnt/hgfs/cmacws/data1/data/cmip5/giss/e2-r/amip/cli_Amon_GISS-E2-R_amip_r1i1p1_188001-195012.nc' 'cli' '0, 360, 4', '-90, 90, 4', '100000,80000,50000,30000, 20000, 10000', 1 /tmp/xxx2.nc; - -#./octaveWrapper 'ncc_noresm' 'ta' 199001 200012 '0, 360, 4' '-90, 90, 4' '100000,80000,50000,30000, 20000, 10000' /tmp/; - -./octaveWrapper 'giss_e2-r' 'ts' 199001 200012 '0, 360, 4' '-90, 90, 4' '-999999' /tmp/;