How to edit datesec array in edgar_v5_2015 emission files (netcdf format) using NCO? - nco

I am using EDGAR V5 2015 emission files (edgar_v5_2015__0.1x0.1.nc) for WRF-Chem simulation. After giving the ncdump -v date,datesec edgar_v5_2015_CO_0.1x0.1.nc > ncdump.log command, I learned that the date and datesec variables of the emission file are- data:
date = 20150101, 20150201, 20150301, 20150401, 20150501, 20150601, 20150701, 20150801, 20150901, 20151001, 20151101, 20151201 ;
datesec = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; }
I want to change the last date in the 'date' array from '20151201' to '20151231'. How to do that using NCO? I have gone through the user guide. But, I am having difficulties understanding what command line I should use for this since I have never used NCO before.

#msi_gerva is correct. The symbol lookup error appears to be a bug. It will probably disappear if you switch to using an updated NCO (4.7.5 is years old), or rebuild your version 4.7.5 to link to a recent version of netCDF.

Related

Minesweeper algorithm in C++[KOI 2020]

I'm preparing KOI 2022, so, I'm solving KOI 2021, 2020 problems. KOI 2020 contest 1 1st period problem 5(See problem 5 in here)
I want to make <vector<vector<int>> minesweeper(vector<vector<int>> &v) function that works on 5*5 minesweeper.
argument
vector<vector<int>> &v
Numbers in minesweeper that converted to vector. -1 if it is blank.
e.g. {{0, 0, 1, -1, 1}, {-1, 3, 3, -1, 1}, {-1, -1, -1, -1, 0}, {2, 5, -1, 3, -1}, {-1, -1, -1, -1, -1}}
return value
A vector. Size is same with argument. Mine is 1, default is 0.
English translation of KOI 2020 contest 1 1st period problem 5
There is a 5*5 minesweeper puzzle.
There are 11 numbers, and the others are blank.
0
0
1
가
1
나
3
3
1
다
0
2
5
3
라
마
Where is the mine?
A. 가
B. 나
C. 다
D. 라
E. 마
How can I make minesweeper function? I want algorithm description, too.
There two some simple rules to solving Minesweeper:
If a field sees all it's mines then all blank fields don't have mines and can be uncovered.
If a field has as many blank fields as it is missing mines then they all contain mines.
Keep applying those rules over and over till nothing changes.
Now it gets complex because you have to look at combinations of fields. Instead of figuring out lots of special cases for 2, 3, 4 known fields I suggest going straight to a brute force algorithm:
For every blank field next to a know field:
create copies of the map with a mine present and not present
go back to the top to solve each map
if one of the maps results in any known field to not see enough mines then the other case must be the actual solution, apply it and go back to the start
If no progress was made then you have to guess. The above loop can give you probabilities for where mines are and if you know the number of mines total you have a probability for other blank fields. Pick one least likely to have a mine.

Convert Unix Timestamp to Datetime in Power BI

Good morning Stack Overflow,
I have a question, I do have a list of Timestamp, I believe there are Unix Time Stamp, I'd like to convert to datetime on PBI, but I'm getting an error, using the following formula :' #datetime(1957,1,1,0,0,0) + #duration(0,0,0,[Timestamp]) ' , Timestamp is the column that I'd like to convert.
Below a sample list of the data :
Is there a way to fix this issue?
You're close but you need to remember that Unix timestamps are recorded in milliseconds since 1970, not seconds since 1957. Try this instead
#datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [Timestamp]/1000)
Make sure the column is a datetime data type.

PySpark Using collect_list to collect Arrays of Varying Length

I am attempting to use collect_list to collect arrays (and maintain order) from two different data frames.
Test_Data and Train_Data have the same format.
from pyspark.sql import functions as F
from pyspark.sql import Window
w = Window.partitionBy('Group').orderBy('date')
# Train_Data has 4 data points
# Test_Data has 7 data points
# desired target array: [1, 1, 2, 3]
# desired MarchMadInd array: [0, 0, 0, 1, 0, 0, 1]
sorted_list_diff_array_lens = train_data.withColumn('target',
F.collect_list('target').over(w)
)\
test_data.withColumn('MarchMadInd', F.collect_list('MarchMadInd').over(w))\
.groupBy('Group')\
.agg(F.max('target').alias('target'),
F.max('MarchMadInd').alias('MarchMadInd')
)
I realize the syntax is incorrect with "test_data.withColumn", but I want to select the array for the MarchMadInd from the test_date, but the array for the target from the train_data. The desired output would look like the following:
{"target":[1, 1, 2, 3], "MarchMadInd":[0, 0, 0, 1, 0, 0, 1]}
Context: this is for a DeepAR time series model (using AWS) that requires dynamic features to include the prediction period, but the target should be historical data.
The solution involves using a join as recommended by pault.
Create a dataframe with dynamic features of length equal to Training + Prediction period
Create a dataframe with target values of length equal to just the Training period.
Use a LEFT JOIN (with the dynamic feature data on LEFT) to bring these dataframes together
Now, using collect_list will create the desired result.

sorting data on x-axis in google line chart

I'm using google line chart to plot data by timestamp(x-axis).
my problem is that the x-axis is not being sorted automatically by the google charting.
e.g. "15:45:23 678" data point which should be the first in the chart is being shown at #2. If I put it at the first place then it is fine. That means Google chart doesn't care about the data and it plots as it sees them.
The issue is that my data set is huge and sorting it based on x-axis data takes lot of time. is there any flag in the line chart which could sort it in the browser?
below is the sample data:
['x', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6'],
['15:48:13 744', 0, 0, 0, 0, 0, 0],
['15:45:23 678', 5, 17, 36, 3957, 20, 21],
['15:48:18 749', 0, 0, 0, 0, 0, 0]
You can use the following function to sort the underlying DataTable:
data.sort([{column: 0}]);.
Column 0 indicates the x-axis.
This will sort the data in asc order, for desc use data.sort([{column: 0, desc: true}]);
You may also be interested in the getSortedRows(sortColumns) function.
More information about these functions can be read about here
https://developers.google.com/chart/interactive/docs/reference#DataTable_sort
https://developers.google.com/chart/interactive/docs/reference#DataTable_getSortedRows

Filling out select control with python mechanize

I'm trying to fill out the registration for a website with python mechanize. Everything is going well but I can't figure out how to do the select controls. For example, if I'm picking my birthday month, here's the form that I need to fill out:
<SelectControl(mm=[*, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])>
I've viewed all the answers on stackoverflow already and they all seem to be some variation like this:
br.find_control(name="mm").value = ["0"]
or
form["mm"] = ["1"]
The problem here is that it gives me a error ItemNotFoundError: insufficient items with name '0'
item = br.find_control(name="mm" type="select").get("12")
item.selected = True
Nvm I just needed to do br.form['mm'] = ["1"] <--- I selected this but could have picked any of the values they allowed.
I have used all of the following:
br['mm'] = ['9']
br['mm'] = ['9',]
br.form['mm'] = ['9']
br.form['mm'] = ['9',]
I seem to remember one case where the comma was mandatory.