Skip to content

Navigation Menu

Global navigation

Home

Issues

Pull requests

Projects

Discussions

Codespaces

Copilot

Explore

Marketplace

Loading

© 2025 GitHub, Inc.

About Blog Terms Privacy Security Status

jinhanxie  / Ulysses

Navigate back to

jinhanxie

Ulysses

jinhanxie / Ulysses /

Type / to search

Search code, repositories, users, issues, pull requests...

Search

Clear

Search syntax tips

Give feedback

Provide feedback

We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted

Cancel Submit feedback

Saved searches

Use saved searches to filter your results more quickly

Name

Query

To see all available qualifiers, see our documentation.

Cancel Create saved search

Chat with Copilot Open Copilot…

Create new... Your issues Your pull requests
Notifications

Code

Issues 0

Pull requests 0

Actions

Projects 0

Wiki

Security

Insights

Settings

Additional navigation options

Code

Issues

Pull requests

Actions

Projects

Wiki

Security

Insights

Settings

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

Open in github.dev Open in a new github.dev tab Open in codespace

Files

Files

main

Add file

t

README.md

SF_SW_single_case_nlfit_ypym_new.m

collect_plot_t600_errorbar_new.m

forcing_injection_pdf_ytot_t600.m

injection_pcolor_t600.m

Breadcrumbs

Ulysses

/
forcing_injection_pdf_ytot_t600.m

Copy path

Blame

Blame

Latest commit

History
History

286 lines (217 loc) · 7.25 KB

Code 55% faster with GitHub Copilot

Breadcrumbs

Ulysses

/
forcing_injection_pdf_ytot_t600.m

Top

File metadata and controls

Code

Blame

286 lines (217 loc) · 7.25 KB

Code 55% faster with GitHub Copilot

Raw

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

Nf = 6;

load(['energy_sw_tot_nlfit_ytot_Nf_' num2str(Nf) '_t600.mat'])

% l_min = 1/975.7850*480*1024;

% l_max = 1*480*1024;

Nl=128;

lmin = 480;

lmax = 480*600;

log_l_min = log(lmin);

log_l_max = log(lmax);

d_ln_l = (log_l_max - log_l_min)/(Nl-1);

l = exp([log_l_min:d_ln_l:log_l_max]);

Nedge = 20;

d_ln_edge = (log(lmax)-log(lmin))/Nedge;

edges = exp(log(lmin):d_ln_edge:log(lmax));

N = 40000;

eps = zeros(N,Nl);

for n=1:N

% e0 = 0;

s_now=1;

for p = Nl:-1:1

% p_now = 0;

if l(p) > 480*600/k_inj_tot_ytot(n,s_now)

% eps(n,p)=e0;

p_now = p;

else

eps(n,p_now) = e_inj_tot_ytot(n,s_now);

% eps(n,p_now-1) = e_inj_tot_ytot(n,s_now);

s_now=s_now+1;

end

if s_now > Nf

% eps(n,1:p) = zeros(1,p)*e0;

break

end

end

end

H_e_pos = zeros(N,Nl);

H_e_neg = zeros(N,Nl);

Nerror = 4000;

for p = 1:N

e_max = max(eps(p,:));

e_min = min(eps(p,:));

for q = 1:Nl

if eps(p,q)>0 && eps(p,q)>e_max/Nerror

H_e_pos(p,q) = 1;

end

if eps(p,q)<0 && eps(p,q)<e_min/Nerror

H_e_neg(p,q) = 1;

end

end

end

Neav = floor(Nl/(Nedge-1));

e_sum_1 = sum(eps,1);

emean_1 = movmean(e_sum_1,Neav);

e_sum_pos_1 = sum(eps.*H_e_pos,1);

emean_pos_1 = movmean(e_sum_pos_1,Neav);

e_sum_neg_1 = sum(eps.*H_e_neg,1);

emean_neg_1 = movmean(e_sum_neg_1,Neav);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Nf = 7;

load(['energy_sw_tot_nlfit_ytot_Nf_' num2str(Nf) '_t600.mat'])

% l_min = 1/975.7850*480*1024;

% l_max = 1*480*1024;

%

%

% Nedge = 20;

% d_ln_edge = (log(l_max)-log(l_min))/Nedge;

% edges = exp(log(l_min):d_ln_edge:log(l_max));

% Nl=256;

% lmin = 480;

% lmax = 480*1024;

% log_l_min = log(lmin);

% log_l_max = log(lmax);

% d_ln_l = (log_l_max - log_l_min)/(Nl-1);

%

% l = exp([log_l_min:d_ln_l:log_l_max]);

%

%

% N = 40000;

eps = zeros(N,Nl);

for n=1:N

% e0 = 0;

s_now=1;

for p = Nl:-1:1

% p_now = 0;

if l(p) > 480*600/k_inj_tot_ytot(n,s_now)

% eps(n,p)=e0;

p_now = p;

else

eps(n,p_now) = e_inj_tot_ytot(n,s_now);

% eps(n,p_now-1) = e_inj_tot_ytot(n,s_now);

s_now=s_now+1;

end

if s_now > Nf

% eps(n,1:p) = zeros(1,p)*e0;

break

end

end

end

H_e_pos = zeros(N,Nl);

H_e_neg = zeros(N,Nl);

Nerror = 4000;

for p = 1:N

e_max = max(eps(p,:));

e_min = min(eps(p,:));

for q = 1:Nl

if eps(p,q)>0 && eps(p,q)>e_max/Nerror

H_e_pos(p,q) = 1;

end

if eps(p,q)<0 && eps(p,q)<e_min/Nerror

H_e_neg(p,q) = 1;

end

end

end

Neav = floor(Nl/(Nedge-1));

e_sum_2 = sum(eps,1);

emean_2 = movmean(e_sum_2,Neav);

e_sum_pos_2 = sum(eps.*H_e_pos,1);

emean_pos_2 = movmean(e_sum_pos_2,Neav);

e_sum_neg_2 = sum(eps.*H_e_neg,1);

emean_neg_2 = movmean(e_sum_neg_2,Neav);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

emean = (emean_1+emean_2)/2;

emean_pos = (emean_pos_1+emean_pos_2)/2;

emean_neg = (emean_neg_1+emean_neg_2)/2;

emean=movmean(emean,Neav);

emean_pos=movmean(emean_pos,Neav);

emean_neg=movmean(emean_neg,Neav);

Hpos = zeros(Nf,40000);

Hneg = zeros(Nf,40000);

% when e<e/Nsmall will be considered as noise

Nsmall = 4;

for j=1:40000

% e_max = max(e_inj_tot_ytot(j,:));

% e_min = min(e_inj_tot_ytot(j,:));

e_abs = max(e_inj_tot_ytot(j,:)) - min(e_inj_tot_ytot(j,:));

for p = 1:Nf

% if e_inj_tot_ytot(j,p)>e_max/Nsmall

if e_inj_tot_ytot(j,p)>e_abs/Nsmall

Hpos(p,j)=1;

end

% if e_inj_tot_ytot(j,p)<e_min/Nsmall

if e_inj_tot_ytot(j,p)<e_abs/Nsmall

Hneg(p,j)=1;

end

end

end

figure

h = histogram(Hpos.*1./k_inj_tot_ytot'*480*1024,edges);

dBin=h.BinEdges(2)-h.BinEdges(1);

h_L=h.BinEdges(2:end)-dBin/2;

l_pos_pdf = h.Values/sum(sum(Hpos));

semilogx(h_L,h.Values/sum(sum(Hpos)),'linewidth',1.3)

hold on

semilogx(h_L,movmean(l_pos_pdf,3),'linewidth',1.3)

title('pdf of forcing scale (positive)','interpreter','latex')

xlabel('$$r$$','interpreter','latex')

ylabel('$$pdf$$','interpreter','latex')

% figure

% h = histogram(Hpos.*1./k_inj_tot_ytot'*480*1024,edges,'Normalization','probability');

% title('pdf of forcing scale (positive)','interpreter','latex')

% xlabel('$$r$$','interpreter','latex')

% ylabel('$$pdf$$','interpreter','latex')

% set(gca,'xscal','log')

%

% figure

%

% h = histogram(Hneg.*1./k_inj_tot_ytot'*480*1024,edges);

% dBin=h.BinEdges(2)-h.BinEdges(1);

% h_L=h.BinEdges(2:end)-dBin/2;

% l_neg_pdf = h.Values/sum(sum(Hneg));

% semilogx(h_L,h.Values/sum(sum(Hneg)),'linewidth',1.3)

% title('pdf of forcing scale (negative)','interpreter','latex')

% xlabel('$$r$$','interpreter','latex')

% ylabel('$$pdf$$','interpreter','latex')

%

% figure

% h = histogram(Hneg.*1./k_inj_tot_ytot'*480*1024,edges,'Normalization','probability');

% title('pdf of forcing scale (negative)','interpreter','latex')

% xlabel('$$r$$','interpreter','latex')

% ylabel('$$pdf$$','interpreter','latex')

% set(gca,'xscal','log')

% energy injection rate

figure

% semilogx(h_L,movmean(l_pos_pdf,1),'LineWidth',2)

% hold on

% semilogx(h_L,movmean(l_neg_pdf,1),'LineWidth',2)

% semilogx(l,emean/sum(emean)*length(l)/length(h_L),'LineWidth',2)

% hold on

% semilogx(l,emean_pos/sum(emean_pos)*length(l)/length(h_L),'LineWidth',2)

% semilogx(l,emean_neg/sum(emean_neg)*length(l)/length(h_L),'LineWidth',2)

% semilogx(l*750,emean*length(l)/length(h_L)/N/7e5,'LineWidth',2)

% hold on

semilogx(l*750,1e9*emean_pos*length(l)/length(h_L)/N/7e5,'r','LineWidth',2)

hold on

semilogx(l*750,1e9*emean_neg*length(l)/length(h_L)/N/7e5,'b','LineWidth',2)

semilogx(l*750,0*emean_pos*length(l)/length(h_L)/N/7e5,'k--','LineWidth',1)

xlim([lmin*750 lmax*750])

% leg=legend('total injection distribution','injection distribution ($$\epsilon>0$$)','dissipation distribution ($$\epsilon<0$$)');

leg=legend('injection distribution','dissipation distribution');

set(leg,'interpreter','latex')

xlabel('$$r\,(km)$$','interpreter','latex')

ylabel('$$\epsilon\,(m^2s^{-3})$$','interpreter','latex')

set(gca,'fontname','times','fontsize',14)

figure

semilogy(1e9*emean_pos*length(l)/length(h_L)/N/7e5,l*750,'r','LineWidth',2)

hold on

semilogy(1e9*emean_neg*length(l)/length(h_L)/N/7e5,l*750,'b','LineWidth',2)

semilogy(0*emean_pos*length(l)/length(h_L)/N/7e5,l*750,'k--','LineWidth',1)

ylim([lmin*750 lmax*750])

% leg=legend('total injection distribution','injection distribution ($$\epsilon>0$$)','dissipation distribution ($$\epsilon<0$$)');

leg=legend('injection distribution','dissipation distribution');

set(leg,'interpreter','latex')

% ylabel('$$r\,(km)$$','interpreter','latex')

xlabel('$$\epsilon\,(m^2s^{-3})$$','interpreter','latex')

set(gca,'fontname','times','fontsize',14)

Footer

© 2025 GitHub, Inc.

Footer navigation

Terms

Privacy

Security

Status

Docs

Contact

Manage cookies

Do not share my personal information

You can’t perform that action at this time.